結果
問題 |
No.2217 Suffix+
|
ユーザー |
|
提出日時 | 2023-02-18 01:33:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 1,459 ms |
コンパイル使用メモリ | 165,648 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 16:07:53 |
合計ジャッジ時間 | 3,293 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define REP(i,n) for(int i=0;i<int(n);i++) ll a[100010],N,K,KK; bool check(ll x){ ll c=0; K=KK; for(ll i=1;i<=N;i++){ if(a[i]+c>=x) continue; else{ ll k=(x-a[i]-c+i-1)/i; if(K-k>=0){ K-=k; c+=k*i; } else return false; } } return true; } int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll i,j,k; cin >> N >> KK; for(i=1;i<=N;i++) cin >> a[i]; ll ok=-1,ng=1e15; while(ng-ok>1){ ll mid=(ok+ng)/2; if(check(mid)) ok=mid; else ng=mid; } cout << ok << endl; return 0; }