結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
|
提出日時 | 2021-03-15 20:28:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 283 bytes |
コンパイル時間 | 2,837 ms |
コンパイル使用メモリ | 196,248 KB |
最終ジャッジ日時 | 2025-01-19 17:20:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n,i,k,ans; cin >> n >> k; vector<int> a(n); for(i=0; i<n; i++){ cin >> a[i]; } sort(a.begin(),a.end(),greater<int>()); ans=a[0]; for(i=1; i<k && a[i]>0; i++){ ans+=a[i]; } cout << ans << endl; return 0; }