結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-17 21:24:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 105 ms / 2,000 ms |
| コード長 | 815 bytes |
| コンパイル時間 | 1,988 ms |
| コンパイル使用メモリ | 195,420 KB |
| 最終ジャッジ日時 | 2025-02-10 16:13:05 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, k;
std::cin >> n >> k;
std::vector<i64> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
i64 lo = 0, hi = 2E14;
while (lo < hi) {
i64 x = (lo + hi + 1) / 2;
i64 need = 0;
i64 add = 0;
for (int i = 0; i < n; i++) {
i64 cur = a[i] + add;
if (cur < x) {
i64 t = (x - cur + i) / (i + 1);
need += t;
add += t * (i + 1);
}
}
if (need <= k) {
lo = x;
} else {
hi = x - 1;
}
}
std::cout << lo << "\n";
return 0;
}