# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
879810 |
2023-11-28T07:22:19 Z |
TAhmed33 |
Akcija (COCI21_akcija) |
C++ |
|
5000 ms |
236548 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 25;
typedef long long ll;
int n; pair <ll, ll> a[MAXN];
vector <pair <ll, ll>> dp[2][MAXN];
bool comb (pair <ll, ll> &a, pair <ll, ll> &b) {
return a.first == b.first ? a.second < b.second : a.first > b.first;
}
int main () {
cin >> n; int k; cin >> k;
for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
sort(a + 1, a + n + 1, [] (pair <ll, ll> &x, pair <ll, ll> &y) { return x.second < y.second; });
for (int j = 0; j <= n + 1; j++) dp[(n + 1) & 1][j].push_back({0, 0});
for (int i = n; i >= 1; i--) {
for (int j = 0; j <= n; j++) {
dp[i & 1][j].clear();
dp[i & 1][j] = dp[(i + 1) & 1][j];
if (j + 1 > a[i].second) continue;
if (j + 1 <= a[i].second) {
for (auto [x, y] : dp[(i + 1) & 1][j + 1]) {
dp[i & 1][j].push_back({x + 1, y + a[i].first});
}
}
sort(dp[i & 1][j].begin(), dp[i & 1][j].end(), comb);
while ((int)dp[i & 1][j].size() > k) dp[i & 1][j].pop_back();
}
}
for (auto [x, y] : dp[1][0]) cout << x << " " << y << '\n';
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:21:27: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
21 | for (auto [x, y] : dp[(i + 1) & 1][j + 1]) {
| ^
Main.cpp:29:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
29 | for (auto [x, y] : dp[1][0]) cout << x << " " << y << '\n';
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
600 KB |
Output is correct |
2 |
Correct |
40 ms |
604 KB |
Output is correct |
3 |
Correct |
64 ms |
756 KB |
Output is correct |
4 |
Correct |
34 ms |
600 KB |
Output is correct |
5 |
Correct |
67 ms |
604 KB |
Output is correct |
6 |
Correct |
12 ms |
692 KB |
Output is correct |
7 |
Correct |
14 ms |
604 KB |
Output is correct |
8 |
Correct |
11 ms |
608 KB |
Output is correct |
9 |
Correct |
13 ms |
600 KB |
Output is correct |
10 |
Correct |
24 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
600 KB |
Output is correct |
2 |
Correct |
40 ms |
604 KB |
Output is correct |
3 |
Correct |
64 ms |
756 KB |
Output is correct |
4 |
Correct |
34 ms |
600 KB |
Output is correct |
5 |
Correct |
67 ms |
604 KB |
Output is correct |
6 |
Correct |
12 ms |
692 KB |
Output is correct |
7 |
Correct |
14 ms |
604 KB |
Output is correct |
8 |
Correct |
11 ms |
608 KB |
Output is correct |
9 |
Correct |
13 ms |
600 KB |
Output is correct |
10 |
Correct |
24 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
38 ms |
752 KB |
Output is correct |
15 |
Correct |
40 ms |
612 KB |
Output is correct |
16 |
Correct |
33 ms |
612 KB |
Output is correct |
17 |
Correct |
33 ms |
608 KB |
Output is correct |
18 |
Correct |
67 ms |
612 KB |
Output is correct |
19 |
Correct |
11 ms |
612 KB |
Output is correct |
20 |
Correct |
14 ms |
604 KB |
Output is correct |
21 |
Correct |
18 ms |
604 KB |
Output is correct |
22 |
Correct |
12 ms |
604 KB |
Output is correct |
23 |
Correct |
24 ms |
740 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 |
136 ms |
860 KB |
Output is correct |
2 |
Correct |
82 ms |
860 KB |
Output is correct |
3 |
Correct |
83 ms |
1112 KB |
Output is correct |
4 |
Correct |
70 ms |
856 KB |
Output is correct |
5 |
Correct |
96 ms |
884 KB |
Output is correct |
6 |
Correct |
11 ms |
548 KB |
Output is correct |
7 |
Correct |
13 ms |
708 KB |
Output is correct |
8 |
Correct |
15 ms |
604 KB |
Output is correct |
9 |
Correct |
15 ms |
604 KB |
Output is correct |
10 |
Correct |
41 ms |
604 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 |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1880 KB |
Output is correct |
2 |
Correct |
13 ms |
1632 KB |
Output is correct |
3 |
Correct |
10 ms |
1376 KB |
Output is correct |
4 |
Correct |
6 ms |
1124 KB |
Output is correct |
5 |
Correct |
16 ms |
2140 KB |
Output is correct |
6 |
Correct |
1 ms |
356 KB |
Output is correct |
7 |
Correct |
5 ms |
868 KB |
Output is correct |
8 |
Correct |
2 ms |
616 KB |
Output is correct |
9 |
Correct |
2 ms |
616 KB |
Output is correct |
10 |
Correct |
1 ms |
360 KB |
Output is correct |
11 |
Correct |
0 ms |
548 KB |
Output is correct |
12 |
Correct |
1 ms |
356 KB |
Output is correct |
13 |
Correct |
8 ms |
1500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
1124 KB |
Output is correct |
2 |
Correct |
27 ms |
1196 KB |
Output is correct |
3 |
Correct |
23 ms |
1128 KB |
Output is correct |
4 |
Correct |
23 ms |
1128 KB |
Output is correct |
5 |
Correct |
29 ms |
1128 KB |
Output is correct |
6 |
Correct |
1 ms |
612 KB |
Output is correct |
7 |
Correct |
4 ms |
616 KB |
Output is correct |
8 |
Correct |
2 ms |
548 KB |
Output is correct |
9 |
Correct |
3 ms |
436 KB |
Output is correct |
10 |
Correct |
12 ms |
872 KB |
Output is correct |
11 |
Correct |
0 ms |
360 KB |
Output is correct |
12 |
Correct |
1 ms |
360 KB |
Output is correct |
13 |
Correct |
7 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
600 KB |
Output is correct |
2 |
Correct |
40 ms |
604 KB |
Output is correct |
3 |
Correct |
64 ms |
756 KB |
Output is correct |
4 |
Correct |
34 ms |
600 KB |
Output is correct |
5 |
Correct |
67 ms |
604 KB |
Output is correct |
6 |
Correct |
12 ms |
692 KB |
Output is correct |
7 |
Correct |
14 ms |
604 KB |
Output is correct |
8 |
Correct |
11 ms |
608 KB |
Output is correct |
9 |
Correct |
13 ms |
600 KB |
Output is correct |
10 |
Correct |
24 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
38 ms |
752 KB |
Output is correct |
15 |
Correct |
40 ms |
612 KB |
Output is correct |
16 |
Correct |
33 ms |
612 KB |
Output is correct |
17 |
Correct |
33 ms |
608 KB |
Output is correct |
18 |
Correct |
67 ms |
612 KB |
Output is correct |
19 |
Correct |
11 ms |
612 KB |
Output is correct |
20 |
Correct |
14 ms |
604 KB |
Output is correct |
21 |
Correct |
18 ms |
604 KB |
Output is correct |
22 |
Correct |
12 ms |
604 KB |
Output is correct |
23 |
Correct |
24 ms |
740 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 |
136 ms |
860 KB |
Output is correct |
28 |
Correct |
82 ms |
860 KB |
Output is correct |
29 |
Correct |
83 ms |
1112 KB |
Output is correct |
30 |
Correct |
70 ms |
856 KB |
Output is correct |
31 |
Correct |
96 ms |
884 KB |
Output is correct |
32 |
Correct |
11 ms |
548 KB |
Output is correct |
33 |
Correct |
13 ms |
708 KB |
Output is correct |
34 |
Correct |
15 ms |
604 KB |
Output is correct |
35 |
Correct |
15 ms |
604 KB |
Output is correct |
36 |
Correct |
41 ms |
604 KB |
Output is correct |
37 |
Correct |
1 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
536 KB |
Output is correct |
40 |
Correct |
19 ms |
1880 KB |
Output is correct |
41 |
Correct |
13 ms |
1632 KB |
Output is correct |
42 |
Correct |
10 ms |
1376 KB |
Output is correct |
43 |
Correct |
6 ms |
1124 KB |
Output is correct |
44 |
Correct |
16 ms |
2140 KB |
Output is correct |
45 |
Correct |
1 ms |
356 KB |
Output is correct |
46 |
Correct |
5 ms |
868 KB |
Output is correct |
47 |
Correct |
2 ms |
616 KB |
Output is correct |
48 |
Correct |
2 ms |
616 KB |
Output is correct |
49 |
Correct |
1 ms |
360 KB |
Output is correct |
50 |
Correct |
0 ms |
548 KB |
Output is correct |
51 |
Correct |
1 ms |
356 KB |
Output is correct |
52 |
Correct |
8 ms |
1500 KB |
Output is correct |
53 |
Correct |
28 ms |
1124 KB |
Output is correct |
54 |
Correct |
27 ms |
1196 KB |
Output is correct |
55 |
Correct |
23 ms |
1128 KB |
Output is correct |
56 |
Correct |
23 ms |
1128 KB |
Output is correct |
57 |
Correct |
29 ms |
1128 KB |
Output is correct |
58 |
Correct |
1 ms |
612 KB |
Output is correct |
59 |
Correct |
4 ms |
616 KB |
Output is correct |
60 |
Correct |
2 ms |
548 KB |
Output is correct |
61 |
Correct |
3 ms |
436 KB |
Output is correct |
62 |
Correct |
12 ms |
872 KB |
Output is correct |
63 |
Correct |
0 ms |
360 KB |
Output is correct |
64 |
Correct |
1 ms |
360 KB |
Output is correct |
65 |
Correct |
7 ms |
860 KB |
Output is correct |
66 |
Execution timed out |
5043 ms |
236548 KB |
Time limit exceeded |
67 |
Halted |
0 ms |
0 KB |
- |