結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 12 ms
4,352 KB
testcase_15 AC 12 ms
4,352 KB
testcase_16 AC 26 ms
4,352 KB
testcase_17 AC 17 ms
4,352 KB
testcase_18 AC 15 ms
4,348 KB
testcase_19 AC 74 ms
4,348 KB
testcase_20 AC 68 ms
4,348 KB
testcase_21 AC 14 ms
4,348 KB
testcase_22 AC 71 ms
4,348 KB
testcase_23 AC 63 ms
4,348 KB
testcase_24 AC 54 ms
4,352 KB
testcase_25 AC 53 ms
4,352 KB
testcase_26 AC 55 ms
4,348 KB
testcase_27 AC 55 ms
4,352 KB
testcase_28 AC 54 ms
4,348 KB
testcase_29 AC 121 ms
4,348 KB
testcase_30 AC 124 ms
4,352 KB
testcase_31 AC 119 ms
4,352 KB
testcase_32 AC 122 ms
4,352 KB
testcase_33 AC 133 ms
4,352 KB
testcase_34 AC 60 ms
4,352 KB
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 153 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
AC

iに干渉できるのは j=0~iのみ

最大値の最小値とかは決め打ちが便利

AGC009Dに似てる
*/
#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