結果

問題 No.1808 Fullgold Alchemist
ユーザー zezerozezero
提出日時 2022-01-14 22:03:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 80,348 KB
最終ジャッジ日時 2025-01-27 11:28:03
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

void slove(){
   int n;
   ll m;
   cin >> n >> m;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];
   auto can = [&](ll x){
     vector<ll> b = a;
     for (int i = 0; i < n;i++){
       if (b[i] < x*m) return false;
       if (i < n-1) b[i+1] += b[i]-x*m; 
     }
     return true;
   };
   ll l = -1,r = 1e9 + 7;
   while(r-l > 1){
     ll mid = (l+r)/2;
     if (can(mid)) l = mid;
     else r = mid;
   }
   cout << l << endl;
 
}
int main(){
  int tt = 1;
  //cin >> tt;
  while(tt--){
   slove();
  }
  return 0;
}
0