Submission #03036


ソースコード

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:04:22
言語 C++11
状態 Accepted
得点 5
ソースコード長 671 Byte
最大実行時間 306 ms
最大メモリ使用量 8188 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 11 ms 476 KB
1
in2.txt AC 10 ms 484 KB
1
in3.txt AC 13 ms 588 KB
1
in4.txt AC 11 ms 560 KB
1
in5.txt AC 11 ms 532 KB
1
in6.txt AC 14 ms 504 KB
1
in7.txt AC 11 ms 472 KB
1
in8.txt AC 11 ms 568 KB
1
in9.txt AC 18 ms 504 KB
1
in10.txt AC 18 ms 704 KB
1
in11.txt AC 22 ms 824 KB
1
in12.txt AC 27 ms 916 KB
1
in13.txt AC 34 ms 1108 KB
1
in14.txt AC 39 ms 1228 KB
1
in15.txt AC 40 ms 1192 KB
1
in16.txt AC 306 ms 8188 KB
1