結果
問題 | No.2217 Suffix+ |
ユーザー |
![]() |
提出日時 | 2024-02-22 13:11:15 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 2,195 ms |
コンパイル使用メモリ | 200,448 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-29 04:27:17 |
合計ジャッジ時間 | 4,232 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long INF = 1e15; int n, k; long long l, r = INF, a[N]; bool Check(long long x) { long long cnt = 0, sum = 0; for (int i = 1; i <= n; i++) { if (a[i] + sum < x) { long long j = (x - a[i] - sum + i - 1) / i; cnt += j, sum += i * j; } } return cnt <= k; } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } while (l < r) { long long mid = (l + r + 1) >> 1; Check(mid) ? l = mid : r = mid - 1; } cout << l; return 0; }