結果

問題 No.1046 Fruits Rush
ユーザー kekenx
提出日時 2020-05-26 22:04:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 335 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 171,820 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 03:02:39
合計ジャッジ時間 2,254 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.rbegin(), a.rend());

  int ans = 0;
  for (int i = 0; i < k; ++i) {
    if (a[i] < 0) break;
    ans += a[i];
  }
  cout << ans << '\n';
  return 0;
}
0