Submission #03028


ソースコード

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[100010];
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 17:54:52
言語 C++11
状態 Accepted
得点 100
ソースコード長 670 Byte
最大実行時間 66 ms
最大メモリ使用量 1372 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 11 ms 476 KB
1
in2.txt AC 14 ms 532 KB
1
in3.txt AC 11 ms 504 KB
1
in4.txt AC 14 ms 604 KB
1
in5.txt AC 9 ms 572 KB
1
in6.txt AC 10 ms 548 KB
1
in7.txt AC 11 ms 516 KB
1
in8.txt AC 15 ms 608 KB
1
in9.txt AC 17 ms 668 KB
1
in10.txt AC 21 ms 832 KB
1
in11.txt AC 33 ms 956 KB
1
in12.txt AC 44 ms 1056 KB
1
in13.txt AC 45 ms 1252 KB
1
in14.txt AC 63 ms 1372 KB
1
in15.txt AC 66 ms 1336 KB
1