結果
| 問題 | No.1046 Fruits Rush | 
| コンテスト | |
| ユーザー |  nanophoto12 | 
| 提出日時 | 2020-05-08 21:40:29 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 703 bytes | 
| コンパイル時間 | 2,665 ms | 
| コンパイル使用メモリ | 197,600 KB | 
| 最終ジャッジ日時 | 2025-01-10 08:23:19 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
#define M_PI       3.14159265358979323846   // pi
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)
#include <bits/stdc++.h>
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e15;
int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> as(n);
	rep(i, n)cin >> as[i];
	sort(as.begin(), as.end(), std::greater<ll>());
	ll sum = as[0];
	for (int i = 1; i < k; i++) {
		if (as[i] > 0) {
			sum += as[i];
		}
	}
	cout << sum << endl;
	return 0;
}
            
            
            
        