結果
| 問題 |
No.1740 Alone 'a'
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-11-14 00:28:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 726 bytes |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 42,436 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 09:05:19 |
| 合計ジャッジ時間 | 2,302 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 1 WA * 37 |
ソースコード
/* -*- coding: utf-8 -*-
*
* d.cc: D - Project Planning
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
typedef long long ll;
/* global variables */
ll as[MAX_N];
/* subroutines */
bool check(int n, int k, ll x) {
ll sum = 0;
for (int i = 0; i < n; i++) sum += min(as[i], x);
return (sum >= x * k);
}
/* main */
int main() {
int n, k;
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++) scanf("%lld", as + i);
ll x0 = *min_element(as, as + n);
ll x1 = *max_element(as, as + n) + 1;
while (x0 + 1 < x1) {
ll x = (x0 + x1) / 2;
if (check(n, k, x)) x0 = x;
else x1 = x;
}
printf("%lld\n", x0);
return 0;
}
tnakao0123