結果
問題 | No.1046 Fruits Rush |
ユーザー |
![]() |
提出日時 | 2020-05-08 22:04:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 426 bytes |
コンパイル時間 | 2,676 ms |
コンパイル使用メモリ | 196,884 KB |
最終ジャッジ日時 | 2025-01-10 08:45:24 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#define _LIBCPP_DEBUG 0 #include<bits/stdc++.h> using namespace std; typedef long long int ll; ll MOD = 1e9 + 7; int INF = 1 << 30; int main(void){ int N,K; cin>>N>>K; vector<int> A(N,0); for (int i = 0; i < N; ++i) { cin>>A[i]; } sort(A.begin(),A.end()); int sum=A[N-1]; for (int i = N-K; i < N-1; ++i) { if(A[i]<0) continue; sum+=A[i]; } cout<<sum<<endl; }