結果

問題 No.2217 Suffix+
ユーザー hourenhouren
提出日時 2023-02-17 21:26:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 2,453 ms
コンパイル使用メモリ 166,544 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 18:32:54
合計ジャッジ時間 6,239 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 29 ms
4,376 KB
testcase_15 AC 29 ms
4,384 KB
testcase_16 AC 59 ms
4,380 KB
testcase_17 AC 43 ms
4,380 KB
testcase_18 AC 35 ms
4,376 KB
testcase_19 AC 85 ms
4,376 KB
testcase_20 AC 73 ms
4,376 KB
testcase_21 AC 12 ms
4,376 KB
testcase_22 AC 81 ms
4,380 KB
testcase_23 AC 60 ms
4,380 KB
testcase_24 AC 109 ms
4,380 KB
testcase_25 AC 110 ms
4,380 KB
testcase_26 AC 110 ms
4,376 KB
testcase_27 AC 110 ms
4,380 KB
testcase_28 AC 111 ms
4,380 KB
testcase_29 AC 111 ms
4,380 KB
testcase_30 AC 111 ms
4,380 KB
testcase_31 AC 111 ms
4,376 KB
testcase_32 AC 109 ms
4,380 KB
testcase_33 AC 111 ms
4,380 KB
testcase_34 AC 111 ms
4,384 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 111 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ok = 0, ng = 1e15;
    while(ng-ok>1){
        ll md = (ng+ok)/2, tot = 0, x = 0;
        rep(i,n){
            ll z = max((md-a[i]-tot+i)/(i+1), 0LL);
            tot += z * (i+1);
            x += z;
        }
        if(x<=k) ok = md;
        else ng = md;
    }
    cout << ok << '\n';
    return 0;
}
0