結果
| 問題 |
No.2217 Suffix+
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-26 13:19:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 748 bytes |
| コンパイル時間 | 837 ms |
| コンパイル使用メモリ | 81,472 KB |
| 実行使用メモリ | 13,640 KB |
| 最終ジャッジ日時 | 2024-11-15 21:06:22 |
| 合計ジャッジ時間 | 34,880 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 TLE * 10 |
ソースコード
#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],b[MR];
bool check(LL x){
memcpy(b,a,sizeof(a));
LL cnt=0;
for(int i=1;i<=n;i++){
if(b[i]<x){
LL t=ceil(1.0*(x-b[i])/i);
cnt+=t;
for(int j=i;j<=n;j++) b[j]+=t*i;
}
}
return cnt<=k;
}
int main(){
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) scanf("%lld",a+i);
LL l=0,r=1e18;
while(l+1<r){
LL mid=(l+r)/2;
if(check(mid)){
l=mid;
}
else{
r=mid;
}
}
printf("%lld\n",l);
return 0;
}