結果
| 問題 |
No.1808 Fullgold Alchemist
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-01-15 22:57:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 766 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 42,176 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 04:47:47 |
| 合計ジャッジ時間 | 2,232 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1808.cc: No.1808 Fullgold Alchemist - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
typedef long long ll;
/* global variables */
int as[MAX_N];
/* subroutines */
bool check(int n, int x) {
ll sum = 0;
for (int i = 0; i < n; i++) {
if (x > as[i] + sum) return false;
sum += as[i] - x;
}
return true;
}
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", as + i);
int maxa = *max_element(as, as + n);
int x0 = 0, x1 = maxa + 1;
while (x0 + 1 < x1) {
int x = (x0 + x1) / 2;
if (check(n, x)) x0 = x;
else x1 = x;
}
printf("%d\n", x0 / m);
return 0;
}
tnakao0123