結果

問題 No.1808 Fullgold Alchemist
ユーザー もひもひーともひもひーと
提出日時 2022-04-10 16:42:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,965 bytes
コンパイル時間 1,488 ms
コンパイル使用メモリ 168,172 KB
実行使用メモリ 4,900 KB
最終ジャッジ日時 2023-08-20 22:15:40
合計ジャッジ時間 6,373 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 30 ms
4,524 KB
testcase_06 AC 58 ms
4,684 KB
testcase_07 AC 58 ms
4,596 KB
testcase_08 AC 87 ms
4,900 KB
testcase_09 AC 84 ms
4,564 KB
testcase_10 AC 82 ms
4,568 KB
testcase_11 AC 78 ms
4,692 KB
testcase_12 AC 54 ms
4,708 KB
testcase_13 AC 56 ms
4,648 KB
testcase_14 AC 56 ms
4,596 KB
testcase_15 AC 56 ms
4,564 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 14 ms
4,380 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 12 ms
4,380 KB
testcase_27 AC 16 ms
4,380 KB
testcase_28 AC 71 ms
4,376 KB
testcase_29 AC 24 ms
4,380 KB
testcase_30 AC 21 ms
4,376 KB
testcase_31 AC 63 ms
4,480 KB
testcase_32 AC 39 ms
4,380 KB
testcase_33 AC 53 ms
4,376 KB
testcase_34 AC 69 ms
4,380 KB
testcase_35 AC 48 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include<set>
#include<stack>
#include<deque>
#include<cassert>
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
//#define INF 10000000
class UnionFind{
    public:
    vector<int> par;

    UnionFind(int n) : par(n){
        for(int i=0; i<n; i++) par[i] = -1;
    }

    int root(int x){
        if(par[x] == -1) return x;
        int next = par[x];
        return root(next);
    }

    void unite(int x, int y){
        int px = root(x);
        int py = root(y);
        if(px == py) return;
        par[px] = py;
    }

    bool same(int x, int y){
        int px = root(x);
        int py = root(y);
        if(px == py) return true;
        else return false; 
    }
};



bool isPrime(int x){
    bool prime = true;
    for(int i=2; i<x; i++){
        if(x%i == 0){
            prime = false;
            break;
        }
    }
    if(!prime) return false;
    return true;
}


//------------------------------------------------------------------------//

ll n,m;
vector<ll> a;

bool isOk(ll key){
    ll t = key*m;
    ll sum = 0;
    bool res = true;
    for(int i=0; i<n; i++){
        sum += a[i];
        if(sum < t){
            res = false;
            break;
        }
        t += key*m;
    }
    return res;
}

int main(){
    cin >> n >> m;
    a.resize(n);
    rep(i,n) cin >> a[i];

    ll right = 1000000010;
    ll left = 0;
    while(right - left > 1){
        ll mid = (right + left)/2;
        if(isOk(mid)) left = mid;
        else right = mid;
    }
    cout << left << endl;
}
0