# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1035860 | 2024-07-26T16:58:32 Z | Andrey | Catfish Farm (IOI22_fish) | C++17 | 141 ms | 55784 KB |
#include "fish.h" #include<bits/stdc++.h> using namespace std; vector<pair<long long,long long>> haha[150000]; vector<long long> dp[150000][3]; long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) { for(long long i = 0; i < m; i++) { haha[x[i]+1].push_back({y[i],w[i]}); } haha[0].push_back({0,0}); for(long long i = 0; i <= n; i++) { haha[i].push_back({n,0}); sort(haha[i].begin(),haha[i].end()); for(long long j = 1; j < haha[i].size(); j++) { haha[i][j] = {haha[i][j].first,haha[i][j].second+haha[i][j-1].second}; } for(long long j = haha[i].size()-1; j >= 1; j--) { haha[i][j] = {haha[i][j].first,haha[i][j-1].second}; } haha[i][0] = {haha[i][0].first,0}; } long long ans = 0; dp[0][0].push_back(0); dp[0][1].push_back(-LLONG_MAX/2); dp[0][2].push_back(-LLONG_MAX/2); dp[0][0].push_back(-LLONG_MAX/2); dp[0][1].push_back(-LLONG_MAX/2); dp[0][2].push_back(-LLONG_MAX/2); for(long long i = 1; i <= n; i++) { for(long long j = 0; j < haha[i].size(); j++) { dp[i][0].push_back(-LLONG_MAX/2); dp[i][1].push_back(-LLONG_MAX/2); dp[i][2].push_back(-LLONG_MAX/2); } long long x = -LLONG_MAX/2,y = haha[i-1].size()-1; for(long long j = haha[i].size()-1; j >= 0; j--) { while(y >= 0 && (j == 0 || haha[i-1][y].first > haha[i][j-1].first)) { x = max(x,max(dp[i-1][2][y],dp[i-1][0][y])+haha[i][j].second); y--; } dp[i][2][j] = max(dp[i][2][j],x-haha[i][j].second); } y = 0; for(long long j = 0; j < haha[i].size(); j++) { while(y < haha[i-1].size() && (y == 0 || haha[i-1][y-1].first < haha[i][j].first)) { dp[i][1][j] = max(dp[i][1][j],max(dp[i-1][0][y],dp[i-1][2][y])+haha[i][j].second); y++; } } x = -LLONG_MAX/2; y = 0; for(long long j = 0; j < haha[i].size(); j++) { while(y < haha[i-1].size() && (y == 0 || haha[i-1][y-1].first < haha[i][j].first)) { x = max(x,dp[i-1][1][y]-haha[i-1][y].second); x = max(x,dp[i-1][0][y]-haha[i-1][y].second); y++; } dp[i][0][j] = max(dp[i][0][j],x+haha[i-1][y-1].second); } x = -LLONG_MAX/2; y = haha[i-1].size()-1; for(long long j = haha[i].size()-1; j >= 0; j--) { while(y >= 0 && (j == 0 || haha[i-1][y].first > haha[i][j-1].first)) { x = max(x,dp[i-1][1][y]); y--; } dp[i][0][j] = max(dp[i][0][j],x); } } for(long long i = 0; i < haha[n].size(); i++) { ans = max(ans,dp[n][0][i]); ans = max(ans,dp[n][1][i]); ans = max(ans,dp[n][2][i]); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 32448 KB | Output is correct |
2 | Correct | 59 ms | 35268 KB | Output is correct |
3 | Correct | 21 ms | 27044 KB | Output is correct |
4 | Correct | 22 ms | 26968 KB | Output is correct |
5 | Correct | 112 ms | 53144 KB | Output is correct |
6 | Correct | 137 ms | 55784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 14424 KB | Output is correct |
2 | Correct | 72 ms | 39100 KB | Output is correct |
3 | Correct | 80 ms | 43188 KB | Output is correct |
4 | Correct | 54 ms | 32452 KB | Output is correct |
5 | Correct | 51 ms | 35260 KB | Output is correct |
6 | Correct | 7 ms | 14684 KB | Output is correct |
7 | Correct | 7 ms | 14424 KB | Output is correct |
8 | Correct | 6 ms | 14444 KB | Output is correct |
9 | Correct | 7 ms | 14428 KB | Output is correct |
10 | Correct | 21 ms | 26844 KB | Output is correct |
11 | Correct | 21 ms | 26972 KB | Output is correct |
12 | Correct | 45 ms | 32708 KB | Output is correct |
13 | Correct | 58 ms | 35256 KB | Output is correct |
14 | Correct | 45 ms | 32484 KB | Output is correct |
15 | Correct | 50 ms | 34464 KB | Output is correct |
16 | Correct | 45 ms | 32276 KB | Output is correct |
17 | Correct | 49 ms | 34248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 26972 KB | Output is correct |
2 | Correct | 22 ms | 26972 KB | Output is correct |
3 | Correct | 45 ms | 28772 KB | Output is correct |
4 | Correct | 36 ms | 29012 KB | Output is correct |
5 | Correct | 60 ms | 32852 KB | Output is correct |
6 | Correct | 56 ms | 32340 KB | Output is correct |
7 | Correct | 56 ms | 32876 KB | Output is correct |
8 | Correct | 64 ms | 32852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 14428 KB | Output is correct |
2 | Correct | 6 ms | 14524 KB | Output is correct |
3 | Correct | 6 ms | 14428 KB | Output is correct |
4 | Correct | 6 ms | 14428 KB | Output is correct |
5 | Correct | 6 ms | 14428 KB | Output is correct |
6 | Correct | 6 ms | 14440 KB | Output is correct |
7 | Correct | 6 ms | 14428 KB | Output is correct |
8 | Correct | 6 ms | 14428 KB | Output is correct |
9 | Correct | 6 ms | 14428 KB | Output is correct |
10 | Correct | 7 ms | 14632 KB | Output is correct |
11 | Correct | 7 ms | 14424 KB | Output is correct |
12 | Correct | 6 ms | 14468 KB | Output is correct |
13 | Correct | 6 ms | 14428 KB | Output is correct |
14 | Correct | 6 ms | 14424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 14428 KB | Output is correct |
2 | Correct | 6 ms | 14524 KB | Output is correct |
3 | Correct | 6 ms | 14428 KB | Output is correct |
4 | Correct | 6 ms | 14428 KB | Output is correct |
5 | Correct | 6 ms | 14428 KB | Output is correct |
6 | Correct | 6 ms | 14440 KB | Output is correct |
7 | Correct | 6 ms | 14428 KB | Output is correct |
8 | Correct | 6 ms | 14428 KB | Output is correct |
9 | Correct | 6 ms | 14428 KB | Output is correct |
10 | Correct | 7 ms | 14632 KB | Output is correct |
11 | Correct | 7 ms | 14424 KB | Output is correct |
12 | Correct | 6 ms | 14468 KB | Output is correct |
13 | Correct | 6 ms | 14428 KB | Output is correct |
14 | Correct | 6 ms | 14424 KB | Output is correct |
15 | Correct | 8 ms | 14428 KB | Output is correct |
16 | Correct | 7 ms | 14660 KB | Output is correct |
17 | Correct | 17 ms | 18304 KB | Output is correct |
18 | Correct | 18 ms | 19548 KB | Output is correct |
19 | Correct | 18 ms | 19288 KB | Output is correct |
20 | Correct | 17 ms | 19292 KB | Output is correct |
21 | Correct | 19 ms | 19280 KB | Output is correct |
22 | Correct | 36 ms | 24272 KB | Output is correct |
23 | Correct | 9 ms | 15196 KB | Output is correct |
24 | Correct | 14 ms | 17240 KB | Output is correct |
25 | Correct | 7 ms | 14424 KB | Output is correct |
26 | Correct | 8 ms | 15192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 14428 KB | Output is correct |
2 | Correct | 6 ms | 14524 KB | Output is correct |
3 | Correct | 6 ms | 14428 KB | Output is correct |
4 | Correct | 6 ms | 14428 KB | Output is correct |
5 | Correct | 6 ms | 14428 KB | Output is correct |
6 | Correct | 6 ms | 14440 KB | Output is correct |
7 | Correct | 6 ms | 14428 KB | Output is correct |
8 | Correct | 6 ms | 14428 KB | Output is correct |
9 | Correct | 6 ms | 14428 KB | Output is correct |
10 | Correct | 7 ms | 14632 KB | Output is correct |
11 | Correct | 7 ms | 14424 KB | Output is correct |
12 | Correct | 6 ms | 14468 KB | Output is correct |
13 | Correct | 6 ms | 14428 KB | Output is correct |
14 | Correct | 6 ms | 14424 KB | Output is correct |
15 | Correct | 8 ms | 14428 KB | Output is correct |
16 | Correct | 7 ms | 14660 KB | Output is correct |
17 | Correct | 17 ms | 18304 KB | Output is correct |
18 | Correct | 18 ms | 19548 KB | Output is correct |
19 | Correct | 18 ms | 19288 KB | Output is correct |
20 | Correct | 17 ms | 19292 KB | Output is correct |
21 | Correct | 19 ms | 19280 KB | Output is correct |
22 | Correct | 36 ms | 24272 KB | Output is correct |
23 | Correct | 9 ms | 15196 KB | Output is correct |
24 | Correct | 14 ms | 17240 KB | Output is correct |
25 | Correct | 7 ms | 14424 KB | Output is correct |
26 | Correct | 8 ms | 15192 KB | Output is correct |
27 | Correct | 7 ms | 14856 KB | Output is correct |
28 | Correct | 62 ms | 37268 KB | Output is correct |
29 | Correct | 88 ms | 42580 KB | Output is correct |
30 | Correct | 90 ms | 42576 KB | Output is correct |
31 | Correct | 92 ms | 42580 KB | Output is correct |
32 | Correct | 81 ms | 47868 KB | Output is correct |
33 | Correct | 91 ms | 42576 KB | Output is correct |
34 | Correct | 91 ms | 42576 KB | Output is correct |
35 | Correct | 48 ms | 26196 KB | Output is correct |
36 | Correct | 90 ms | 45904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 26972 KB | Output is correct |
2 | Correct | 22 ms | 26972 KB | Output is correct |
3 | Correct | 45 ms | 28772 KB | Output is correct |
4 | Correct | 36 ms | 29012 KB | Output is correct |
5 | Correct | 60 ms | 32852 KB | Output is correct |
6 | Correct | 56 ms | 32340 KB | Output is correct |
7 | Correct | 56 ms | 32876 KB | Output is correct |
8 | Correct | 64 ms | 32852 KB | Output is correct |
9 | Correct | 53 ms | 32592 KB | Output is correct |
10 | Correct | 49 ms | 29776 KB | Output is correct |
11 | Correct | 94 ms | 45136 KB | Output is correct |
12 | Correct | 6 ms | 14428 KB | Output is correct |
13 | Correct | 6 ms | 14428 KB | Output is correct |
14 | Correct | 6 ms | 14492 KB | Output is correct |
15 | Correct | 5 ms | 14428 KB | Output is correct |
16 | Correct | 6 ms | 14428 KB | Output is correct |
17 | Correct | 6 ms | 14428 KB | Output is correct |
18 | Correct | 21 ms | 26972 KB | Output is correct |
19 | Correct | 20 ms | 26972 KB | Output is correct |
20 | Correct | 21 ms | 26972 KB | Output is correct |
21 | Correct | 21 ms | 26972 KB | Output is correct |
22 | Correct | 60 ms | 35152 KB | Output is correct |
23 | Correct | 96 ms | 45160 KB | Output is correct |
24 | Correct | 94 ms | 45904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 32448 KB | Output is correct |
2 | Correct | 59 ms | 35268 KB | Output is correct |
3 | Correct | 21 ms | 27044 KB | Output is correct |
4 | Correct | 22 ms | 26968 KB | Output is correct |
5 | Correct | 112 ms | 53144 KB | Output is correct |
6 | Correct | 137 ms | 55784 KB | Output is correct |
7 | Correct | 6 ms | 14424 KB | Output is correct |
8 | Correct | 72 ms | 39100 KB | Output is correct |
9 | Correct | 80 ms | 43188 KB | Output is correct |
10 | Correct | 54 ms | 32452 KB | Output is correct |
11 | Correct | 51 ms | 35260 KB | Output is correct |
12 | Correct | 7 ms | 14684 KB | Output is correct |
13 | Correct | 7 ms | 14424 KB | Output is correct |
14 | Correct | 6 ms | 14444 KB | Output is correct |
15 | Correct | 7 ms | 14428 KB | Output is correct |
16 | Correct | 21 ms | 26844 KB | Output is correct |
17 | Correct | 21 ms | 26972 KB | Output is correct |
18 | Correct | 45 ms | 32708 KB | Output is correct |
19 | Correct | 58 ms | 35256 KB | Output is correct |
20 | Correct | 45 ms | 32484 KB | Output is correct |
21 | Correct | 50 ms | 34464 KB | Output is correct |
22 | Correct | 45 ms | 32276 KB | Output is correct |
23 | Correct | 49 ms | 34248 KB | Output is correct |
24 | Correct | 22 ms | 26972 KB | Output is correct |
25 | Correct | 22 ms | 26972 KB | Output is correct |
26 | Correct | 45 ms | 28772 KB | Output is correct |
27 | Correct | 36 ms | 29012 KB | Output is correct |
28 | Correct | 60 ms | 32852 KB | Output is correct |
29 | Correct | 56 ms | 32340 KB | Output is correct |
30 | Correct | 56 ms | 32876 KB | Output is correct |
31 | Correct | 64 ms | 32852 KB | Output is correct |
32 | Correct | 6 ms | 14428 KB | Output is correct |
33 | Correct | 6 ms | 14524 KB | Output is correct |
34 | Correct | 6 ms | 14428 KB | Output is correct |
35 | Correct | 6 ms | 14428 KB | Output is correct |
36 | Correct | 6 ms | 14428 KB | Output is correct |
37 | Correct | 6 ms | 14440 KB | Output is correct |
38 | Correct | 6 ms | 14428 KB | Output is correct |
39 | Correct | 6 ms | 14428 KB | Output is correct |
40 | Correct | 6 ms | 14428 KB | Output is correct |
41 | Correct | 7 ms | 14632 KB | Output is correct |
42 | Correct | 7 ms | 14424 KB | Output is correct |
43 | Correct | 6 ms | 14468 KB | Output is correct |
44 | Correct | 6 ms | 14428 KB | Output is correct |
45 | Correct | 6 ms | 14424 KB | Output is correct |
46 | Correct | 8 ms | 14428 KB | Output is correct |
47 | Correct | 7 ms | 14660 KB | Output is correct |
48 | Correct | 17 ms | 18304 KB | Output is correct |
49 | Correct | 18 ms | 19548 KB | Output is correct |
50 | Correct | 18 ms | 19288 KB | Output is correct |
51 | Correct | 17 ms | 19292 KB | Output is correct |
52 | Correct | 19 ms | 19280 KB | Output is correct |
53 | Correct | 36 ms | 24272 KB | Output is correct |
54 | Correct | 9 ms | 15196 KB | Output is correct |
55 | Correct | 14 ms | 17240 KB | Output is correct |
56 | Correct | 7 ms | 14424 KB | Output is correct |
57 | Correct | 8 ms | 15192 KB | Output is correct |
58 | Correct | 7 ms | 14856 KB | Output is correct |
59 | Correct | 62 ms | 37268 KB | Output is correct |
60 | Correct | 88 ms | 42580 KB | Output is correct |
61 | Correct | 90 ms | 42576 KB | Output is correct |
62 | Correct | 92 ms | 42580 KB | Output is correct |
63 | Correct | 81 ms | 47868 KB | Output is correct |
64 | Correct | 91 ms | 42576 KB | Output is correct |
65 | Correct | 91 ms | 42576 KB | Output is correct |
66 | Correct | 48 ms | 26196 KB | Output is correct |
67 | Correct | 90 ms | 45904 KB | Output is correct |
68 | Correct | 53 ms | 32592 KB | Output is correct |
69 | Correct | 49 ms | 29776 KB | Output is correct |
70 | Correct | 94 ms | 45136 KB | Output is correct |
71 | Correct | 6 ms | 14428 KB | Output is correct |
72 | Correct | 6 ms | 14428 KB | Output is correct |
73 | Correct | 6 ms | 14492 KB | Output is correct |
74 | Correct | 5 ms | 14428 KB | Output is correct |
75 | Correct | 6 ms | 14428 KB | Output is correct |
76 | Correct | 6 ms | 14428 KB | Output is correct |
77 | Correct | 21 ms | 26972 KB | Output is correct |
78 | Correct | 20 ms | 26972 KB | Output is correct |
79 | Correct | 21 ms | 26972 KB | Output is correct |
80 | Correct | 21 ms | 26972 KB | Output is correct |
81 | Correct | 60 ms | 35152 KB | Output is correct |
82 | Correct | 96 ms | 45160 KB | Output is correct |
83 | Correct | 94 ms | 45904 KB | Output is correct |
84 | Correct | 111 ms | 52164 KB | Output is correct |
85 | Correct | 112 ms | 52976 KB | Output is correct |
86 | Correct | 141 ms | 52916 KB | Output is correct |
87 | Correct | 130 ms | 54100 KB | Output is correct |
88 | Correct | 5 ms | 14428 KB | Output is correct |
89 | Correct | 135 ms | 54124 KB | Output is correct |
90 | Correct | 117 ms | 54612 KB | Output is correct |
91 | Correct | 111 ms | 55376 KB | Output is correct |