結果
問題 |
No.2217 Suffix+
|
ユーザー |
![]() |
提出日時 | 2023-08-29 10:48:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 2,147 ms |
コンパイル使用メモリ | 190,392 KB |
最終ジャッジ日時 | 2025-02-16 15:28:13 |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long; const int MAXN = 1e5 + 3; int n; LL k, a[MAXN]; bool as(LL MIN){ LL _k = k; for(LL i = 1, s = 0; i <= n; i++){ if(a[i] + s < MIN){ LL cnt = (MIN - (a[i] + s) + i - 1) / i; _k -= cnt; if(_k < 0) return 0; s += cnt * i; } } return 1; } int main(){ ios::sync_with_stdio(0), cin.tie(0); cin >> n>> k; for(int i = 1; i <= n; i++){ cin >> a[i]; } LL l = 0, r = 1e17; while(l < r){ LL mid = (l + r + 1) >> 1; if(as(mid)){ l = mid; }else{ r = mid - 1; } } cout << l; return 0; }