結果
| 問題 | No.2217 Suffix+ |
| コンテスト | |
| ユーザー |
nono00
|
| 提出日時 | 2023-03-03 14:30:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 135 ms / 2,000 ms |
| コード長 | 876 bytes |
| コンパイル時間 | 714 ms |
| コンパイル使用メモリ | 71,652 KB |
| 最終ジャッジ日時 | 2025-02-11 01:26:07 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <iostream>
#include <vector>
int main() {
int n, k;
std::cin >> n >> k;
std::vector<long long> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
auto check = [&](long long key) -> bool {
long long sum = 0;
long long count = 0;
for (int i = 0; i < n; i++) {
if (a[i] + sum < key) {
long long temp = (key - (sum + a[i]) + i) / (i + 1);
sum += temp * (i + 1);
count += temp;
}
if (count > k) {
return false;
}
}
return true;
};
long long ok = 0;
long long ng = 1e15;
while (ng - ok > 1) {
long long key = (ok + ng) / 2;
if (check(key)) {
ok = key;
} else {
ng = key;
}
}
std::cout << ok << '\n';
}
nono00