結果

問題 No.2217 Suffix+
ユーザー HIcoderHIcoder
提出日時 2023-07-13 19:08:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 1,109 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 108,768 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 08:05:40
合計ジャッジ時間 6,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<set> 
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N+1);
    ll lb=INF;
    for(int i=1;i<=N;i++){
        cin>>A[i];
        lb=min(lb,A[i]);
    }

    ll ub=INF;//lbは必ず達成できる

    while(ub-lb>1){
        ll mid=(ub+lb)/2;//mid以上にできるかどうか

        ll cnt=0;

        ll tot=0;

        for(int i=1;i<=N;i++){
            ll t=max(mid-(tot+A[i]),0LL);
            if(t>0){
                //(t+(i-1))/i回, 足さないといけない
                ll step=(t+(i-1))/i;
                tot+=step*i;//i~Nにたされる数

                cnt+=step;
            }
        }

        //K回以下でmidに達成できない
        if(K<cnt){
            ub=mid;
        }else{
            lb=mid;
        }
    
    }

    cout<<lb<<endl;



}
0