結果

問題 No.2217 Suffix+
ユーザー ace_amuroace_amuro
提出日時 2023-03-28 12:00:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 81,488 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 07:06:16
合計ジャッジ時間 5,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 14 ms
4,348 KB
testcase_15 AC 13 ms
4,348 KB
testcase_16 AC 26 ms
4,348 KB
testcase_17 AC 19 ms
4,348 KB
testcase_18 AC 16 ms
4,348 KB
testcase_19 AC 82 ms
4,348 KB
testcase_20 AC 76 ms
4,348 KB
testcase_21 AC 17 ms
4,348 KB
testcase_22 AC 79 ms
4,348 KB
testcase_23 AC 70 ms
4,348 KB
testcase_24 AC 61 ms
4,348 KB
testcase_25 AC 60 ms
4,348 KB
testcase_26 AC 61 ms
4,348 KB
testcase_27 AC 61 ms
4,348 KB
testcase_28 AC 61 ms
4,348 KB
testcase_29 AC 140 ms
4,348 KB
testcase_30 AC 139 ms
4,348 KB
testcase_31 AC 137 ms
4,348 KB
testcase_32 AC 137 ms
4,348 KB
testcase_33 AC 138 ms
4,348 KB
testcase_34 AC 64 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 167 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e5+10;
int n,k;
LL a[MR];
bool check(LL x){
    LL sum=0,cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i]+sum<x){
            LL t=(x-a[i]-sum+i-1)/i;
            cnt+=t;
            sum+=t*i;
        }
    }
    return cnt<=k;
}
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    LL l=0,r=1e18;
    while(l+1<r){
        LL mid=(l+r)/2;
        if(check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    cout<<l<<endl;
    return 0;
}
0