結果
問題 | No.2217 Suffix+ |
ユーザー |
![]() |
提出日時 | 2023-02-17 21:34:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 191 ms / 2,000 ms |
コード長 | 832 bytes |
コンパイル時間 | 2,085 ms |
コンパイル使用メモリ | 196,408 KB |
最終ジャッジ日時 | 2025-02-10 16:25:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (long long i=0;i<(long long)(n);i++) #define all(v) v.begin(),v.end() using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; const ll INF=(1ll<<60); template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } int main(){ ll n,k; cin >> n >> k; vector<ll> a(n); rep(i,n) cin >> a[i]; ll ng=INF,ok=0; while(1<abs(ok-ng)){ ll mid=(ok+ng)/2; vector<ll> b(n); rep(i,n) b[i]=max(0ll,mid-a[i]); ll cnt=0,now=0; rep(i,n){ ll x=max(0ll,(b[i]-now+i+1-1)/(i+1)); cnt+=x; now+=x*(i+1); } if(cnt<=k) ok=mid; else ng=mid; } cout << ok << endl; }