結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-17 21:36:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 77 ms / 2,000 ms |
| コード長 | 859 bytes |
| コンパイル時間 | 1,898 ms |
| コンパイル使用メモリ | 194,732 KB |
| 最終ジャッジ日時 | 2025-02-10 16:29:52 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
long long N, K; cin >> N >> K;
vector<long long> A(N); for (long long &i : A) cin >> i;
auto check = [&](long long x) -> bool {
long long offset = 0, operations = 0;
for (long long i = 0; i < N && operations <= K; ++i) {
if (A[i] + offset < x) {
operations += (x - A[i] - offset + i) / (i + 1);
offset += (x - A[i] - offset + i) / (i + 1) * (i + 1);
}
}
return operations <= K;
};
long long L = 1, R = 1e15, ans = 0;
while (R >= L) {
long long M = L + R >> 1;
if (check(M) == true) {
ans = M;
L = M + 1;
} else {
R = M - 1;
}
}
cout << ans << endl;
}