結果
| 問題 |
No.1046 Fruits Rush
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-05-08 21:23:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 471 bytes |
| コンパイル時間 | 2,392 ms |
| コンパイル使用メモリ | 196,756 KB |
| 最終ジャッジ日時 | 2025-01-10 07:57:18 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
rep(i,n) cin >> a[i];
sort(a.begin(), a.end(), greater<int>());
int res = a[0];
int sum = res;
for (int i = 1; i < k; i++) {
sum += a[i];
res = max(res, sum);
}
cout << res << endl;
return 0;
}
iqueue02