Submission #03032


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int n, k;
ll a[100010];
bool C(ll t){
ll sum = 0;
for(int i = 0; i < n; ++i){
if(a[i] > t){
sum += (a[i] - t + k - 1) / k;
}
}
return sum <= t;
}
int main(){
scanf("%d", &n);
for(int i = 0; i < n; ++i) scanf("%lld", &a[i]);
scanf("%d", &k);
--k;
ll l = 0, u = 0;
for(int i = 0; i < n; ++i) u = max(u, a[i]);
if(k == 0){
printf("%lld\n", u);
return 0;
}
while(u - l > 1){
ll mid = (l + u) / 2;
if(C(mid)){
u = mid;
}
else{
l = mid;
}
}
printf("%lld\n", u);
return 0;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 12 ms 472 KB
1
in2.txt AC 13 ms 524 KB
1
in3.txt AC 14 ms 496 KB
1
in4.txt AC 11 ms 728 KB
1
in5.txt AC 10 ms 572 KB
1
in6.txt AC 13 ms 672 KB
1
in7.txt AC 11 ms 644 KB
1
in8.txt AC 14 ms 604 KB
1
in9.txt AC 15 ms 672 KB
1
in10.txt AC 18 ms 700 KB
1
in11.txt AC 26 ms 828 KB
1
in12.txt AC 29 ms 1052 KB
1
in13.txt AC 29 ms 1248 KB
1
in14.txt AC 38 ms 1360 KB
1
in15.txt AC 43 ms 1324 KB
1