結果

問題 No.1046 Fruits Rush
ユーザー Haar
提出日時 2020-05-08 21:23:19
言語 C++17
(gcc 13.3.0 + boost 1.87.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
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0