結果

問題 No.2217 Suffix+
ユーザー Manuel1024
提出日時 2023-10-03 01:56:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 712 ms
コンパイル使用メモリ 71,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-26 13:57:42
合計ジャッジ時間 4,308 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n, k; cin >> n >> k;
    vector<ll> a(n);
    for(auto &it: a) cin >> it;

    ll ac = 0, wa = 1LL << 60;
    while(wa-ac > 1){
        ll wj = (wa+ac)/2;
        ll k1 = k;
        ll tot = 0;
        for(int i = 0; i < n; i++){
            if(wj <= a[i]+tot) continue;
            ll x = wj-(a[i]+tot);
            x = (x+i)/(i+1);
            tot += x*(i+1);
            k1 -= x;
            if(k1 < 0) break;
        }
        (k1 < 0 ? wa : ac) = wj;
    }
    cout << ac << endl;
    return 0;
}
0