# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
906431 | 2024-01-14T09:23:47 Z | SalihSahin | Akcija (COCI21_akcija) | C++17 | 5000 ms | 91184 KB |
#include<bits/stdc++.h> #define int long long #define pb push_back #define mp make_pair using namespace std; const int mod = 1e9 + 7; const int inf = 1e17*2; const int N = 2e5 + 5; int32_t main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, k; cin>>n>>k; multiset<int> best[n+2]; best[0].insert(0); vector<pair<int, int> > a(n); for(int i = 0; i < n; i++){ cin>>a[i].second>>a[i].first; } sort(a.begin(), a.end()); for(int i = 0; i < n; i++){ for(int j = a[i].first-1; j >= 0; j--){ for(auto itr: best[j]){ int val = a[i].second + itr; if(best[j+1].size() >= j+1){ auto kp = best[j+1].rbegin(); if(val < *kp){ best[j+1].insert(val); if(best[j+1].size() > j+1){ auto p = best[j+1].end(); p--; best[j+1].erase(p); } } else break; } else{ best[j+1].insert(val); } } } } vector<pair<int, int> > ans; for(int i = n; i >= 0; i--){ for(auto itr: best[i]){ ans.pb(mp(i, itr)); } if(ans.size() > k) break; } for(int i = 0; i < k; i++){ cout<<ans[i].first<<" "<<ans[i].second<<endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 205 ms | 84680 KB | Output is correct |
2 | Correct | 224 ms | 91184 KB | Output is correct |
3 | Correct | 186 ms | 74320 KB | Output is correct |
4 | Correct | 180 ms | 76148 KB | Output is correct |
5 | Correct | 229 ms | 89812 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 42 ms | 20564 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 205 ms | 84680 KB | Output is correct |
2 | Correct | 224 ms | 91184 KB | Output is correct |
3 | Correct | 186 ms | 74320 KB | Output is correct |
4 | Correct | 180 ms | 76148 KB | Output is correct |
5 | Correct | 229 ms | 89812 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 42 ms | 20564 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Execution timed out | 5061 ms | 16532 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5016 ms | 16420 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 205 ms | 84680 KB | Output is correct |
2 | Correct | 224 ms | 91184 KB | Output is correct |
3 | Correct | 186 ms | 74320 KB | Output is correct |
4 | Correct | 180 ms | 76148 KB | Output is correct |
5 | Correct | 229 ms | 89812 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 42 ms | 20564 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Execution timed out | 5061 ms | 16532 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |