Submission #03035


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int lld;
lld n;
lld a[1000010];
lld k;
bool solve(lld t){
lld sum = 0;
for(lld i=0;i<n;i++){
if(a[i] > t){
sum += (a[i] - t + k - 1) / k;
}
}
return (sum<=t);
}
int main(){
cin >> n;
lld left = 0,right = 0;
for(lld i=0;i<n;i++){
cin >> a[i];
//scanf("%lld",&a[i]);
right = max(right,a[i]);
}
cin >> k;
k--;
if(k == 0){
cout << right << endl;
return 0;
}
while(left < right){
lld mid = (left+right)/2;
if(solve(mid)) right = mid;
else left = mid+1;
}
cout << left << endl;
}

ステータス

項目 データ
問題 0382 - 「とっぴー」カウンセリング
ユーザー名 ei1428
投稿日時 2016-04-21 18:03:47
言語 C++11
状態 Accepted
得点 5
ソースコード長 671 Byte
最大実行時間 528 ms
最大メモリ使用量 8332 KB

セット

セット 得点 Cases
1 ALL 5 / 5 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 13 ms 476 KB
1
in2.txt AC 12 ms 492 KB
1
in3.txt AC 11 ms 592 KB
1
in4.txt AC 10 ms 564 KB
1
in5.txt AC 13 ms 540 KB
1
in6.txt AC 13 ms 388 KB
1
in7.txt AC 13 ms 608 KB
1
in8.txt AC 12 ms 576 KB
1
in9.txt AC 14 ms 760 KB
1
in10.txt AC 19 ms 704 KB
1
in11.txt AC 33 ms 836 KB
1
in12.txt AC 42 ms 1064 KB
1
in13.txt AC 49 ms 1132 KB
1
in14.txt AC 59 ms 1248 KB
1
in15.txt AC 65 ms 1332 KB
1
in16.txt AC 528 ms 8332 KB
1