結果

問題 No.1046 Fruits Rush
ユーザー ytflhjoytflhjo
提出日時 2020-05-10 10:52:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 171,772 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 06:39:49
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> vec;
    for(int i = 0; i < n;i++){
        int b;
        cin >> b;
        vec.push_back(b);
    }
    int ans = 0;
    sort(vec.begin(),vec.end(),greater<int>());
    for(int i = 0;i < k;i++){
        if(vec[i] > 0){
            ans+=vec[i];
        }
    }
    cout << ans << endl;
}



0