Submission #03668
ソースコード
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 56 57 58 59 60 61 62 63 64 | #include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define fr first #define sc second #define Rep(i,n) for(int i=0;i<(n);i++) #define Rrep(i, m, n) for(int i=(m);i<(n);i++) #define All(v) v.begin(),v.end() #define Uniq(v) v.erase(unique(All(v)),v.end()) typedef pair< int , int > Pii; typedef pair< int , Pii> Pip; typedef pair<string, int > Psi; typedef vector< int > Vi; const int INF = (1<<30); const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1}; int n, p[1000001], t; int ma = 0; int l = 0, r; bool judge( int day ) { int sum = 0; Rep(i, n) { if ( p[i] > day ) { int tmp = (p[i] - day) % t; if ( tmp == 0 ) sum += (p[i] - day) / t; else sum += (p[i] - day) / t + 1; } if ( sum > day ) return false ; } return true ; } int binary_search() { while ( l != r ) { int mid = (l + r) / 2; if ( judge( mid ) ) { r = mid; } else { l = mid + 1; } } return l; } int main() { cin >> n; Rep(i, n) { cin >> p[i]; ma = max(ma, p[i]); } cin >> t; t--; r = ma; cout << binary_search() << endl; } |
ステータス
項目 | データ |
---|---|
問題 | 0382 - 「とっぴー」カウンセリング |
ユーザー名 | ei1430 |
投稿日時 | 2016-04-28 18:33:09 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1186 Byte |
最大実行時間 | 386 ms |
最大メモリ使用量 | 4372 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 11 ms | 476 KB |
1
|
in2.txt | AC | 10 ms | 444 KB |
1
|
in3.txt | AC | 10 ms | 412 KB |
1
|
in4.txt | AC | 14 ms | 516 KB |
1
|
in5.txt | AC | 14 ms | 488 KB |
1
|
in6.txt | AC | 13 ms | 588 KB |
1
|
in7.txt | AC | 12 ms | 564 KB |
1
|
in8.txt | AC | 14 ms | 656 KB |
1
|
in9.txt | AC | 14 ms | 608 KB |
1
|
in10.txt | AC | 20 ms | 580 KB |
1
|
in11.txt | AC | 26 ms | 696 KB |
1
|
in12.txt | AC | 36 ms | 728 KB |
1
|
in13.txt | AC | 40 ms | 808 KB |
1
|
in14.txt | AC | 47 ms | 852 KB |
1
|
in15.txt | AC | 50 ms | 820 KB |
1
|
in16.txt | AC | 386 ms | 4372 KB |
1
|