結果
| 問題 |
No.1046 Fruits Rush
|
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2020-05-08 21:22:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 348 bytes |
| コンパイル時間 | 404 ms |
| コンパイル使用メモリ | 51,576 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 23:15:41 |
| 合計ジャッジ時間 | 1,099 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <stdio.h>
#include <algorithm>
#include <functional>
int ri() {
int n;
scanf("%d", &n);
return n;
}
int main() {
int n = ri();
int k = ri();
int a[n];
for (auto &i : a) i = ri();
std::sort(a, a + n, std::greater<>());
int res = 0;
for (int i = 0; i < k; i++) if (!i || a[i] > 0) res += a[i];
printf("%d\n", res);
return 0;
}
QCFium