結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
|
提出日時 | 2020-05-08 21:31:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 487 bytes |
コンパイル時間 | 1,152 ms |
コンパイル使用メモリ | 79,532 KB |
最終ジャッジ日時 | 2025-01-10 08:11:20 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 3 |
ソースコード
#include <iostream> #include <algorithm> #include <numeric> #include <vector> void solve() { int n, k; std::cin >> n >> k; std::vector<int> xs(n); for (auto& x : xs) { std::cin >> x; x = std::max(x, 0); } std::sort(xs.rbegin(), xs.rend()); std::cout << std::accumulate(xs.begin(), xs.begin() + k, 0) << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }