結果

問題 No.2217 Suffix+
ユーザー 👑 nu50218nu50218
提出日時 2023-02-17 21:35:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 1,328 bytes
コンパイル時間 4,179 ms
コンパイル使用メモリ 212,972 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 18:45:15
合計ジャッジ時間 6,613 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 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 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 10 ms
4,376 KB
testcase_17 AC 7 ms
4,384 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 53 ms
4,380 KB
testcase_20 AC 51 ms
4,384 KB
testcase_21 AC 12 ms
4,380 KB
testcase_22 AC 52 ms
4,376 KB
testcase_23 AC 49 ms
4,380 KB
testcase_24 AC 21 ms
4,376 KB
testcase_25 AC 21 ms
4,376 KB
testcase_26 AC 21 ms
4,380 KB
testcase_27 AC 21 ms
4,380 KB
testcase_28 AC 21 ms
4,376 KB
testcase_29 AC 84 ms
4,380 KB
testcase_30 AC 84 ms
4,380 KB
testcase_31 AC 84 ms
4,376 KB
testcase_32 AC 84 ms
4,380 KB
testcase_33 AC 85 ms
4,380 KB
testcase_34 AC 22 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 113 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOCAL
#include <local.hpp>
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#define debug(...) (static_cast<void>(0))
#define postprocess() (static_cast<void>(0))
#endif

// #include "atcoder/dsu.hpp"
// #include "atcoder/modint.hpp"
// using mint = atcoder::modint998244353;
// using mint = atcoder::modint1000000007;

using namespace std;
using ll = long long;
using ld = long double;

void solve([[maybe_unused]] int test) {
    ll N, K;
    cin >> N >> K;

    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    auto ok = [&](ll ans) {
        ll required = 0;
        ll sum = 0;

        for (ll i = 0; i < N; i++) {
            ll a = A[i] + sum;
            if (a >= ans) continue;

            ll num = (ans - a + i) / (i + 1);
            required += num;
            sum += num * (i + 1);
        }

        return required <= K;
    };

    ll imin = 0, imax = 1e16;
    while (imax - imin > 1) {
        ll imid = (imin + imax) / 2;
        if (ok(imid)) {
            imin = imid;
        } else {
            imax = imid;
        }
    }

    cout << imin << endl;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    for (int _t = 1; _t <= t; _t++) solve(_t);

    postprocess();
}
0