結果
| 問題 | No.2217 Suffix+ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-02-17 21:30:18 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 132 ms / 2,000 ms | 
| コード長 | 687 bytes | 
| コンパイル時間 | 1,576 ms | 
| コンパイル使用メモリ | 168,136 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 12:31:49 | 
| 合計ジャッジ時間 | 3,920 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 33 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k, INF = 1ll << 61;
    cin >> n >> k;
    vector<ll> a(n);
    for(auto &&v:a)cin >> v;
    ll ok = 0, ng = 1ll << 60, mid;
    while(ok + 1 < ng){
        mid = (ok + ng) / 2;
        ll cnt = 0, s = 0;
        for(int i = 0; i < n; i++){
            if(a[i] + s < mid){
                ll d = i + 1, di = mid - (a[i] + s);
                cnt = min(INF, cnt + (di + d - 1) / d);
                s = min(INF, s + (di + d - 1) / d * d);
            }
        }
        if(cnt <= k) ok = mid;
        else ng = mid;
    }
    cout << ok << '\n';
}
            
            
            
        