結果
問題 |
No.2217 Suffix+
|
ユーザー |
![]() |
提出日時 | 2023-08-29 10:32:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 605 bytes |
コンパイル時間 | 724 ms |
コンパイル使用メモリ | 64,280 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-30 23:11:28 |
合計ジャッジ時間 | 4,650 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <iostream> using namespace std; const int N = 114514; long long a[N], n, k; int ck(long long x) { long long now = 0, cnt = 0, tmp; for(int i = 1; i <= n; i++) { if(a[i] + now < x) { tmp = (x - (a[i] + now) + i - 1) / i; cnt += tmp; now += tmp * i; } } return cnt <= k; } int main(){ cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> a[i]; } long long l = 0, r = 1145141919810114514; while(l < r) { long long mid = (l + r) / 2; if(ck(mid + 1)) { l = mid + 1; } else { r = mid; } } cout << l; return 0; }