結果

問題 No.2217 Suffix+
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-02-19 01:34:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 164,344 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 12:58:31
合計ジャッジ時間 4,956 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 21 ms
4,380 KB
testcase_17 AC 15 ms
4,384 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 46 ms
4,380 KB
testcase_20 AC 44 ms
4,380 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 43 ms
4,376 KB
testcase_23 AC 38 ms
4,380 KB
testcase_24 AC 52 ms
4,380 KB
testcase_25 AC 53 ms
4,376 KB
testcase_26 AC 51 ms
4,376 KB
testcase_27 AC 53 ms
4,376 KB
testcase_28 AC 53 ms
4,376 KB
testcase_29 AC 105 ms
4,380 KB
testcase_30 AC 103 ms
4,376 KB
testcase_31 AC 105 ms
4,376 KB
testcase_32 AC 107 ms
4,380 KB
testcase_33 AC 106 ms
4,376 KB
testcase_34 AC 53 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 114 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

const int N = 1e5 + 10;

int n, k;
i64 a[N];

bool check(i64 m) {
    i64 tot = 0;
    int rk = k;
    for(int i = 1; i <= n; i ++) {
        if(tot + a[i] >= m) continue;
        if((m - tot - a[i] + i - 1) / i > rk) return false;
        rk -= (m - tot - a[i] + i - 1) / i;
        tot += ((m - tot - a[i] + i - 1) / i) * i;
    }
    return true;
}

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    
    i64 l = 0, r = 3e14;
    while(l + 1 < r) {
        i64 mid = (l + r) / 2;
        if(check(mid)) l = mid;
        else r = mid;
    }
    cout << l;
}
0