結果

問題 No.1808 Fullgold Alchemist
ユーザー ace_amuroace_amuro
提出日時 2023-03-30 13:17:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 81,592 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-22 01:22:34
合計ジャッジ時間 3,329 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=2e5+10;
int n,m,a[MR];
bool check(LL x){
    LL r=0;
    for(int i=1;i<=n;i++){
        if(a[i] >= m*x){
            r+=a[i]-m*x;
        }
        else{
            r-=m*x-a[i];
            if(r<0) return false;
        }
    }
    return true;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    int l=0,r=1e9+5;
    while(l+1<r){
        int mid=(l+r)/2;
        if(check(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
    }
    cout<<l<<endl;
    return 0;
}
0