結果
| 問題 | No.1046 Fruits Rush |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-08 21:23:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 315 bytes |
| 記録 | |
| コンパイル時間 | 2,611 ms |
| コンパイル使用メモリ | 198,480 KB |
| 最終ジャッジ日時 | 2025-01-10 07:56:13 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 3 |
ソースコード
#include <bits/stdc++.h>
int main(){
int n, k; std::cin >> n >> k;
std::vector<int> a(n);
for(int i = 0; i < n; ++i){
std::cin >> a[i];
if(a[i] < 0) a[i] = 0;
}
std::sort(a.rbegin(), a.rend());
int ans = std::accumulate(a.begin(), a.begin() + k, 0);
std::cout << ans << "\n";
return 0;
}