結果
問題 |
No.2217 Suffix+
|
ユーザー |
![]() |
提出日時 | 2023-08-29 11:46:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 813 bytes |
コンパイル時間 | 1,881 ms |
コンパイル使用メモリ | 167,840 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-30 23:20:40 |
合計ジャッジ時間 | 4,536 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; unsigned long long n, k, a[MAXN], mins = 1e18, b[MAXN]; bool F(unsigned long long x){ for(int i = 1; i <= n; i++){ if(a[i] < x){ b[i] = x - a[i]; } else { b[i] = 0; } } unsigned long long xx = 0, s = 0; for(int i = 1; i <= n; i++){ if(b[i]){ if(b[i] > s){ xx += (b[i] + i - s - 1) / i; s += (b[i] + i - s - 1) / i * i; } } } return xx <= k; } int main(){ cin >> n >> k; for(int i = 1; i <= n; i++){ cin >> a[i]; mins = min(mins, a[i]); } unsigned long long l = 0, r = mins + k * n; while(l < r){ unsigned long long mid = (l + r + 1) >> 1; if(F(mid)){ l = mid; } else { r = mid - 1; } } cout << l; return 0;// }