結果
問題 |
No.1808 Fullgold Alchemist
|
ユーザー |
|
提出日時 | 2022-04-10 16:42:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 1,965 bytes |
コンパイル時間 | 1,849 ms |
コンパイル使用メモリ | 168,528 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-14 04:52:00 |
合計ジャッジ時間 | 5,031 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#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; }