結果
問題 |
No.2217 Suffix+
|
ユーザー |
|
提出日時 | 2023-03-28 12:00:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 161 ms / 2,000 ms |
コード長 | 750 bytes |
コンパイル時間 | 623 ms |
コンパイル使用メモリ | 81,464 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 02:37:36 |
合計ジャッジ時間 | 4,502 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#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; }