結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
![]() |
提出日時 | 2020-05-08 21:25:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 1,498 ms |
コンパイル使用メモリ | 171,276 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 23:37:56 |
合計ジャッジ時間 | 2,069 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll #define REP(i,n) for(int i=0;i<n;++i) #define ALL(name) name.begin(),name.end() #define SORT(name) sort(name.begin(), name.end()) #define ZERO(p) memset(p, 0, sizeof(p)) #define MINUS(p) memset(p, -1, sizeof(p)) #if 1 # define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__) #else # define DBG(fmt, ...) #endif const ll LLINF = (1LL<<60); const int INF = (1LL<<30); const double DINF = std::numeric_limits<double>::infinity(); const int MOD = 1000000007; #define MAX_N 100010 signed main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; vector<int> A(N); REP(i, N) { cin >> A[i]; } SORT(A); reverse(A.begin(), A.end()); int ans = A[0]; for(int i = 1; i < K; ++i) { if(A[i] <= 0) { break; } ans += A[i]; } printf("%lld\n", ans); return 0; }