結果

問題 No.2217 Suffix+
ユーザー no wayno way
提出日時 2023-02-18 12:09:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 164,948 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-27 05:23:25
合計ジャッジ時間 3,796 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 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 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 10 ms
4,380 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 46 ms
4,384 KB
testcase_20 AC 45 ms
4,380 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 47 ms
4,376 KB
testcase_23 AC 42 ms
4,376 KB
testcase_24 AC 22 ms
4,564 KB
testcase_25 AC 20 ms
4,376 KB
testcase_26 AC 19 ms
4,376 KB
testcase_27 AC 19 ms
4,568 KB
testcase_28 AC 19 ms
4,380 KB
testcase_29 AC 69 ms
4,384 KB
testcase_30 AC 71 ms
4,380 KB
testcase_31 AC 71 ms
4,380 KB
testcase_32 AC 72 ms
4,380 KB
testcase_33 AC 73 ms
4,376 KB
testcase_34 AC 22 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 98 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const long long INF=2e14;
long long a[N];
int n,k;
long long ans;
int check(long long x){
	long long t=0,sum=0;
	for (int i=1;i<=n;i++) if (a[i]+t<x){
		sum+=(x-a[i]-t-1)/i+1;
		t+=1ll*i*((x-a[i]-t-1)/i+1);
	}
	return sum<=k;
}
void s(long long l,long long r){
	if (l>r) return;
	long long mid=(l+r)/2;
	if (check(mid)) ans=mid,s(mid+1,r); else s(l,mid-1);
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	ans=0;
	s(0,INF);
	printf("%lld\n",ans);
}
0