結果
| 問題 |
No.1046 Fruits Rush
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2020-05-08 21:49:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 618 bytes |
| コンパイル時間 | 3,215 ms |
| コンパイル使用メモリ | 219,956 KB |
| 最終ジャッジ日時 | 2025-01-10 08:34:18 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,k;
cin>>n>>k;
int A[n];
rep(i,n){
cin>>A[i];
}
sort(A,A+n);
reverse(A,A+n);
int ans=0;
rep(i,k){
if(i==0)ans+=A[i];
else{
if(A[i]>0) ans+=A[i];
}
}
cout<<ans<<endl;
return 0;
}
umezo