# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
902621 | 2024-01-10T21:00:02 Z | SalihSahin | Akcija (COCI21_akcija) | C++17 | 81 ms | 860 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()); int mx = 0; for(int i = 0; i < n; i++){ for(int j = min(a[i].first-1, mx); j >= max(0LL, mx - (n - i - 1) - 1); j--){ for(auto itr: best[j]){ best[j+1].insert(a[i].second + itr); } while(best[j+1].size() > k){ auto k = best[j+1].end(); k--; best[j+1].erase(k); } if(best[j+1].size()) mx = max(mx, j+1); } } 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 604 KB | Output is correct |
2 | Correct | 39 ms | 600 KB | Output is correct |
3 | Correct | 22 ms | 604 KB | Output is correct |
4 | Correct | 23 ms | 604 KB | Output is correct |
5 | Correct | 26 ms | 604 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 | 2 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 572 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 604 KB | Output is correct |
2 | Correct | 39 ms | 600 KB | Output is correct |
3 | Correct | 22 ms | 604 KB | Output is correct |
4 | Correct | 23 ms | 604 KB | Output is correct |
5 | Correct | 26 ms | 604 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 | 2 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 572 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 34 ms | 600 KB | Output is correct |
15 | Correct | 29 ms | 856 KB | Output is correct |
16 | Correct | 38 ms | 604 KB | Output is correct |
17 | Correct | 38 ms | 600 KB | Output is correct |
18 | Correct | 29 ms | 600 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 2 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 2 ms | 344 KB | Output is correct |
23 | Correct | 10 ms | 604 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 628 KB | Output is correct |
2 | Correct | 76 ms | 660 KB | Output is correct |
3 | Correct | 75 ms | 632 KB | Output is correct |
4 | Correct | 64 ms | 620 KB | Output is correct |
5 | Correct | 81 ms | 640 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 3 ms | 348 KB | Output is correct |
10 | Correct | 23 ms | 600 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 860 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 860 KB | Output is correct |
2 | Correct | 18 ms | 860 KB | Output is correct |
3 | Correct | 16 ms | 604 KB | Output is correct |
4 | Correct | 14 ms | 600 KB | Output is correct |
5 | Correct | 22 ms | 860 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 500 KB | Output is correct |
10 | Correct | 5 ms | 584 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Incorrect | 4 ms | 604 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 604 KB | Output is correct |
2 | Correct | 39 ms | 600 KB | Output is correct |
3 | Correct | 22 ms | 604 KB | Output is correct |
4 | Correct | 23 ms | 604 KB | Output is correct |
5 | Correct | 26 ms | 604 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 | 2 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 572 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 34 ms | 600 KB | Output is correct |
15 | Correct | 29 ms | 856 KB | Output is correct |
16 | Correct | 38 ms | 604 KB | Output is correct |
17 | Correct | 38 ms | 600 KB | Output is correct |
18 | Correct | 29 ms | 600 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 2 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 2 ms | 344 KB | Output is correct |
23 | Correct | 10 ms | 604 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 80 ms | 628 KB | Output is correct |
28 | Correct | 76 ms | 660 KB | Output is correct |
29 | Correct | 75 ms | 632 KB | Output is correct |
30 | Correct | 64 ms | 620 KB | Output is correct |
31 | Correct | 81 ms | 640 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 344 KB | Output is correct |
34 | Correct | 1 ms | 344 KB | Output is correct |
35 | Correct | 3 ms | 348 KB | Output is correct |
36 | Correct | 23 ms | 600 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 344 KB | Output is correct |
40 | Incorrect | 4 ms | 860 KB | Output isn't correct |
41 | Halted | 0 ms | 0 KB | - |