# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080068 | 2024-08-29T06:43:37 Z | serifefedartar | Akcija (COCI21_akcija) | C++17 | 5000 ms | 24584 KB |
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0) typedef long long ll; #define f first #define s second #define LOGN 21 const ll MOD = 1e9 + 7; const ll MAXN = 150; #define int long long vector<pair<int,int>> v; vector<set<int>> dp; signed main() { fast; int n, k; cin >> n >> k; v = vector<pair<int,int>>(n); for (int i = 0; i < n; i++) cin >> v[i].s >> v[i].f; sort(v.begin(), v.end()); dp = vector<set<int>>(n+1, set<int>()); dp[0].insert(0); for (auto u : v) { for (int i = n; i >= 0; i--) { if (i+1 > u.f) continue; for (auto Q : dp[i]) { dp[i + 1].insert(Q + u.s); if (dp[i+1].size() > k) dp[i+1].erase(prev(dp[i+1].end())); } } } for (int i = n; k && i >= 0; i--) { while (k && dp[i].size()) { cout << i << " " << *(dp[i].begin()) << "\n"; k--; dp[i].erase(dp[i].begin()); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 604 KB | Output is correct |
2 | Correct | 14 ms | 672 KB | Output is correct |
3 | Correct | 14 ms | 604 KB | Output is correct |
4 | Correct | 13 ms | 604 KB | Output is correct |
5 | Correct | 22 ms | 668 KB | Output is correct |
6 | Correct | 5 ms | 348 KB | Output is correct |
7 | Correct | 7 ms | 604 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 348 KB | Output is correct |
10 | Correct | 7 ms | 636 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 | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 604 KB | Output is correct |
2 | Correct | 14 ms | 672 KB | Output is correct |
3 | Correct | 14 ms | 604 KB | Output is correct |
4 | Correct | 13 ms | 604 KB | Output is correct |
5 | Correct | 22 ms | 668 KB | Output is correct |
6 | Correct | 5 ms | 348 KB | Output is correct |
7 | Correct | 7 ms | 604 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 348 KB | Output is correct |
10 | Correct | 7 ms | 636 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 | 348 KB | Output is correct |
14 | Correct | 82 ms | 604 KB | Output is correct |
15 | Correct | 52 ms | 604 KB | Output is correct |
16 | Correct | 43 ms | 636 KB | Output is correct |
17 | Correct | 48 ms | 604 KB | Output is correct |
18 | Correct | 56 ms | 600 KB | Output is correct |
19 | Correct | 5 ms | 588 KB | Output is correct |
20 | Correct | 6 ms | 600 KB | Output is correct |
21 | Correct | 5 ms | 596 KB | Output is correct |
22 | Correct | 9 ms | 348 KB | Output is correct |
23 | Correct | 15 ms | 604 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 672 KB | Output is correct |
2 | Correct | 110 ms | 724 KB | Output is correct |
3 | Correct | 89 ms | 660 KB | Output is correct |
4 | Correct | 100 ms | 600 KB | Output is correct |
5 | Correct | 113 ms | 600 KB | Output is correct |
6 | Correct | 5 ms | 344 KB | Output is correct |
7 | Correct | 6 ms | 600 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 7 ms | 348 KB | Output is correct |
10 | Correct | 28 ms | 604 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 1628 KB | Output is correct |
2 | Correct | 10 ms | 1628 KB | Output is correct |
3 | Correct | 7 ms | 1372 KB | Output is correct |
4 | Correct | 5 ms | 1372 KB | Output is correct |
5 | Correct | 11 ms | 1880 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 604 KB | Output is correct |
9 | Correct | 1 ms | 604 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 7 ms | 1372 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 860 KB | Output is correct |
2 | Correct | 19 ms | 604 KB | Output is correct |
3 | Correct | 17 ms | 604 KB | Output is correct |
4 | Correct | 17 ms | 736 KB | Output is correct |
5 | Correct | 21 ms | 852 KB | Output is correct |
6 | Correct | 0 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 | 4 ms | 604 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 5 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 604 KB | Output is correct |
2 | Correct | 14 ms | 672 KB | Output is correct |
3 | Correct | 14 ms | 604 KB | Output is correct |
4 | Correct | 13 ms | 604 KB | Output is correct |
5 | Correct | 22 ms | 668 KB | Output is correct |
6 | Correct | 5 ms | 348 KB | Output is correct |
7 | Correct | 7 ms | 604 KB | Output is correct |
8 | Correct | 5 ms | 348 KB | Output is correct |
9 | Correct | 5 ms | 348 KB | Output is correct |
10 | Correct | 7 ms | 636 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 | 348 KB | Output is correct |
14 | Correct | 82 ms | 604 KB | Output is correct |
15 | Correct | 52 ms | 604 KB | Output is correct |
16 | Correct | 43 ms | 636 KB | Output is correct |
17 | Correct | 48 ms | 604 KB | Output is correct |
18 | Correct | 56 ms | 600 KB | Output is correct |
19 | Correct | 5 ms | 588 KB | Output is correct |
20 | Correct | 6 ms | 600 KB | Output is correct |
21 | Correct | 5 ms | 596 KB | Output is correct |
22 | Correct | 9 ms | 348 KB | Output is correct |
23 | Correct | 15 ms | 604 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 102 ms | 672 KB | Output is correct |
28 | Correct | 110 ms | 724 KB | Output is correct |
29 | Correct | 89 ms | 660 KB | Output is correct |
30 | Correct | 100 ms | 600 KB | Output is correct |
31 | Correct | 113 ms | 600 KB | Output is correct |
32 | Correct | 5 ms | 344 KB | Output is correct |
33 | Correct | 6 ms | 600 KB | Output is correct |
34 | Correct | 5 ms | 348 KB | Output is correct |
35 | Correct | 7 ms | 348 KB | Output is correct |
36 | Correct | 28 ms | 604 KB | Output is correct |
37 | Correct | 0 ms | 344 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 8 ms | 1628 KB | Output is correct |
41 | Correct | 10 ms | 1628 KB | Output is correct |
42 | Correct | 7 ms | 1372 KB | Output is correct |
43 | Correct | 5 ms | 1372 KB | Output is correct |
44 | Correct | 11 ms | 1880 KB | Output is correct |
45 | Correct | 0 ms | 348 KB | Output is correct |
46 | Correct | 2 ms | 604 KB | Output is correct |
47 | Correct | 1 ms | 604 KB | Output is correct |
48 | Correct | 1 ms | 604 KB | Output is correct |
49 | Correct | 0 ms | 348 KB | Output is correct |
50 | Correct | 0 ms | 348 KB | Output is correct |
51 | Correct | 0 ms | 348 KB | Output is correct |
52 | Correct | 7 ms | 1372 KB | Output is correct |
53 | Correct | 23 ms | 860 KB | Output is correct |
54 | Correct | 19 ms | 604 KB | Output is correct |
55 | Correct | 17 ms | 604 KB | Output is correct |
56 | Correct | 17 ms | 736 KB | Output is correct |
57 | Correct | 21 ms | 852 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 1 ms | 348 KB | Output is correct |
60 | Correct | 1 ms | 348 KB | Output is correct |
61 | Correct | 2 ms | 348 KB | Output is correct |
62 | Correct | 4 ms | 604 KB | Output is correct |
63 | Correct | 0 ms | 348 KB | Output is correct |
64 | Correct | 0 ms | 348 KB | Output is correct |
65 | Correct | 5 ms | 604 KB | Output is correct |
66 | Execution timed out | 5008 ms | 24584 KB | Time limit exceeded |
67 | Halted | 0 ms | 0 KB | - |