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