Submission #03592


ソースコード

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<bits/stdc++.h>
#define F first
#define S second
#define INF (1<<30)
#define LLINF (1LL<<60)
using namespace std;
long long N,T,ans,cnt;
vector<long long>P;
main(){
cin>>N;
for(int i=0;i<N;i++){
cin>>cnt;
P.push_back(cnt);
}
cnt=0;
cin>>T;
T--;
sort(P.begin(),P.end(),greater<long long>());
long long left=1;
long long right=1000000001LL;
long long mdl=(left+right)/2;
while(left<right){
mdl=(left+right)/2;
cnt=0;
for(int i=0;i<N&&P[i]>mdl;i++){
cnt+=((P[i]-mdl)/T);
if((P[i]-mdl)%T!=0&&P[i]-mdl>0){
cnt++;
}
}
if(cnt>mdl){
left=mdl+1;
}
else{
right=mdl;
}
}
long long ans=mdl+4;
for(int i=mdl-5;i<=mdl+5;i++){
cnt=0;
for(int j=0;j<N&&P[j]>i;j++){
cnt+=((P[j]-i)/T);
if((P[j]-i)%T!=0&&P[j]-i>0){
cnt++;
}
}
if(cnt<=i){
ans=i;
break;
}
}
cout<<ans<<endl;
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in1.txt AC 11 ms 476 KB
1
in2.txt AC 13 ms 412 KB
1
in3.txt AC 10 ms 512 KB
1
in4.txt AC 10 ms 492 KB
1
in5.txt AC 10 ms 472 KB
1
in6.txt AC 16 ms 572 KB
1
in7.txt AC 11 ms 412 KB
1
in8.txt AC 13 ms 632 KB
1
in9.txt AC 18 ms 624 KB
1
in10.txt AC 23 ms 836 KB
1
in11.txt AC 50 ms 1208 KB
1
in12.txt AC 68 ms 1684 KB
1
in13.txt AC 81 ms 1740 KB
1
in14.txt AC 98 ms 1716 KB
1
in15.txt AC 101 ms 1668 KB
1
in16.txt AC 923 ms 9024 KB
1