結果
| 問題 |
No.1808 Fullgold Alchemist
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-05-25 00:24:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 729 bytes |
| コンパイル時間 | 839 ms |
| コンパイル使用メモリ | 105,568 KB |
| 最終ジャッジ日時 | 2025-02-13 04:43:18 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
ll N, M;
vector<ll> A;
bool solve(ll c){
ll S=0;
for (int i=0; i<N; i++){
if (A[i]>=c) S+= A[i]-c;
else{
S -= c-A[i];
if (S < 0) return 0;
}
}
return 1;
}
int main(){
cin >> N >> M;
A.resize(N);
for (int i=0; i<N; i++) cin >> A[i];
ll l=0, r=1e9+1, c;
while(r-l>1){
c = (l+r)/2;
if(solve(c)) l=c;
else r=c;
}
cout << l/M << endl;
return 0;
}
srjywrdnprkt