結果
問題 | No.2217 Suffix+ |
ユーザー |
![]() |
提出日時 | 2023-02-17 23:06:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 1,669 ms |
コンパイル使用メモリ | 193,740 KB |
最終ジャッジ日時 | 2025-02-10 17:57:20 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n,k; cin>>n>>k; vector<ll> A(n); rep(i,n) cin>>A[i]; auto f=[&](ll x)->bool{ ll tmp=k; ll sum=0; rep(i,n){ if(A[i]+sum>=x) continue; ll t=((x-A[i]-sum+i)/(i+1)); tmp-=t; sum+=t*(i+1); } if(tmp>=0) return true; return false; }; ll ok=0,ng=1e18; while(ng-ok>1){ ll mid=(ok+ng)/2; if(f(mid)) ok=mid; else ng=mid; } cout<<ok<<endl; return 0; }