結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
![]() |
提出日時 | 2020-05-09 00:12:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 365 bytes |
コンパイル時間 | 1,548 ms |
コンパイル使用メモリ | 171,544 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-04 01:20:56 |
合計ジャッジ時間 | 2,191 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N,K; cin >> N >> K; vector<int> A(N); for (int i=0;i<N;++i) cin >> A[i]; sort(A.begin(),A.end()); reverse(A.begin(),A.end()); int ans=-100000,sum=0; for (int i=0;i<K;++i) sum+=A[i],ans=max(ans,sum); cout << ans << '\n'; }