結果
問題 |
No.2217 Suffix+
|
ユーザー |
![]() |
提出日時 | 2024-02-22 10:30:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 1,669 ms |
コンパイル使用メモリ | 167,024 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 04:25:10 |
合計ジャッジ時間 | 4,595 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long INF = 2e14; int n, k; long long l = 0, r = INF, a[N]; bool Check(long long x){ long long sum = 0, pre = 0; for(int i = 1; i <= n; i++){ if(a[i] + pre < x){ long long v = (x - a[i] - pre + i - 1) / i; sum += v; pre += v * i; } } return sum <= k; } int main(){ cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> a[i]; } while(l < r){ long long mid = (l + r + 1) >> 1; Check(mid) ? l = mid : r = mid - 1; } cout << l; return 0; }