# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037438 | 2024-07-28T21:15:55 Z | aaaaaarroz | Catfish Farm (IOI22_fish) | C++17 | 144 ms | 56148 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 | 41 ms | 32196 KB | Output is correct |
2 | Correct | 48 ms | 34496 KB | Output is correct |
3 | Correct | 18 ms | 26972 KB | Output is correct |
4 | Correct | 19 ms | 26968 KB | Output is correct |
5 | Correct | 106 ms | 50604 KB | Output is correct |
6 | Correct | 120 ms | 56148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 14424 KB | Output is correct |
2 | Correct | 69 ms | 37748 KB | Output is correct |
3 | Correct | 81 ms | 41912 KB | Output is correct |
4 | Correct | 40 ms | 32204 KB | Output is correct |
5 | Correct | 49 ms | 34496 KB | Output is correct |
6 | Correct | 3 ms | 14424 KB | Output is correct |
7 | Correct | 3 ms | 14428 KB | Output is correct |
8 | Correct | 3 ms | 14428 KB | Output is correct |
9 | Correct | 4 ms | 14428 KB | Output is correct |
10 | Correct | 18 ms | 26968 KB | Output is correct |
11 | Correct | 18 ms | 26972 KB | Output is correct |
12 | Correct | 52 ms | 32228 KB | Output is correct |
13 | Correct | 55 ms | 34512 KB | Output is correct |
14 | Correct | 42 ms | 31028 KB | Output is correct |
15 | Correct | 45 ms | 32700 KB | Output is correct |
16 | Correct | 41 ms | 30912 KB | Output is correct |
17 | Correct | 55 ms | 32704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 26972 KB | Output is correct |
2 | Correct | 18 ms | 26992 KB | Output is correct |
3 | Correct | 34 ms | 28864 KB | Output is correct |
4 | Correct | 29 ms | 29016 KB | Output is correct |
5 | Correct | 52 ms | 32852 KB | Output is correct |
6 | Correct | 47 ms | 32340 KB | Output is correct |
7 | Correct | 52 ms | 32964 KB | Output is correct |
8 | Correct | 50 ms | 32848 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 14424 KB | Output is correct |
2 | Correct | 3 ms | 14592 KB | Output is correct |
3 | Correct | 3 ms | 14428 KB | Output is correct |
4 | Correct | 3 ms | 14428 KB | Output is correct |
5 | Correct | 3 ms | 14428 KB | Output is correct |
6 | Correct | 3 ms | 14428 KB | Output is correct |
7 | Correct | 3 ms | 14428 KB | Output is correct |
8 | Correct | 3 ms | 14428 KB | Output is correct |
9 | Correct | 3 ms | 14516 KB | Output is correct |
10 | Correct | 4 ms | 14684 KB | Output is correct |
11 | Correct | 3 ms | 14428 KB | Output is correct |
12 | Correct | 3 ms | 14424 KB | Output is correct |
13 | Correct | 3 ms | 14428 KB | Output is correct |
14 | Correct | 4 ms | 14428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 14424 KB | Output is correct |
2 | Correct | 3 ms | 14592 KB | Output is correct |
3 | Correct | 3 ms | 14428 KB | Output is correct |
4 | Correct | 3 ms | 14428 KB | Output is correct |
5 | Correct | 3 ms | 14428 KB | Output is correct |
6 | Correct | 3 ms | 14428 KB | Output is correct |
7 | Correct | 3 ms | 14428 KB | Output is correct |
8 | Correct | 3 ms | 14428 KB | Output is correct |
9 | Correct | 3 ms | 14516 KB | Output is correct |
10 | Correct | 4 ms | 14684 KB | Output is correct |
11 | Correct | 3 ms | 14428 KB | Output is correct |
12 | Correct | 3 ms | 14424 KB | Output is correct |
13 | Correct | 3 ms | 14428 KB | Output is correct |
14 | Correct | 4 ms | 14428 KB | Output is correct |
15 | Correct | 3 ms | 14428 KB | Output is correct |
16 | Correct | 3 ms | 14684 KB | Output is correct |
17 | Correct | 14 ms | 18268 KB | Output is correct |
18 | Correct | 14 ms | 19676 KB | Output is correct |
19 | Correct | 14 ms | 19276 KB | Output is correct |
20 | Correct | 14 ms | 19400 KB | Output is correct |
21 | Correct | 14 ms | 19292 KB | Output is correct |
22 | Correct | 27 ms | 24148 KB | Output is correct |
23 | Correct | 5 ms | 15416 KB | Output is correct |
24 | Correct | 11 ms | 17096 KB | Output is correct |
25 | Correct | 3 ms | 14428 KB | Output is correct |
26 | Correct | 5 ms | 15164 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 14424 KB | Output is correct |
2 | Correct | 3 ms | 14592 KB | Output is correct |
3 | Correct | 3 ms | 14428 KB | Output is correct |
4 | Correct | 3 ms | 14428 KB | Output is correct |
5 | Correct | 3 ms | 14428 KB | Output is correct |
6 | Correct | 3 ms | 14428 KB | Output is correct |
7 | Correct | 3 ms | 14428 KB | Output is correct |
8 | Correct | 3 ms | 14428 KB | Output is correct |
9 | Correct | 3 ms | 14516 KB | Output is correct |
10 | Correct | 4 ms | 14684 KB | Output is correct |
11 | Correct | 3 ms | 14428 KB | Output is correct |
12 | Correct | 3 ms | 14424 KB | Output is correct |
13 | Correct | 3 ms | 14428 KB | Output is correct |
14 | Correct | 4 ms | 14428 KB | Output is correct |
15 | Correct | 3 ms | 14428 KB | Output is correct |
16 | Correct | 3 ms | 14684 KB | Output is correct |
17 | Correct | 14 ms | 18268 KB | Output is correct |
18 | Correct | 14 ms | 19676 KB | Output is correct |
19 | Correct | 14 ms | 19276 KB | Output is correct |
20 | Correct | 14 ms | 19400 KB | Output is correct |
21 | Correct | 14 ms | 19292 KB | Output is correct |
22 | Correct | 27 ms | 24148 KB | Output is correct |
23 | Correct | 5 ms | 15416 KB | Output is correct |
24 | Correct | 11 ms | 17096 KB | Output is correct |
25 | Correct | 3 ms | 14428 KB | Output is correct |
26 | Correct | 5 ms | 15164 KB | Output is correct |
27 | Correct | 4 ms | 14936 KB | Output is correct |
28 | Correct | 58 ms | 37460 KB | Output is correct |
29 | Correct | 84 ms | 42724 KB | Output is correct |
30 | Correct | 90 ms | 42356 KB | Output is correct |
31 | Correct | 85 ms | 42576 KB | Output is correct |
32 | Correct | 91 ms | 47700 KB | Output is correct |
33 | Correct | 91 ms | 42580 KB | Output is correct |
34 | Correct | 112 ms | 42432 KB | Output is correct |
35 | Correct | 35 ms | 26192 KB | Output is correct |
36 | Correct | 85 ms | 45924 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 26972 KB | Output is correct |
2 | Correct | 18 ms | 26992 KB | Output is correct |
3 | Correct | 34 ms | 28864 KB | Output is correct |
4 | Correct | 29 ms | 29016 KB | Output is correct |
5 | Correct | 52 ms | 32852 KB | Output is correct |
6 | Correct | 47 ms | 32340 KB | Output is correct |
7 | Correct | 52 ms | 32964 KB | Output is correct |
8 | Correct | 50 ms | 32848 KB | Output is correct |
9 | Correct | 55 ms | 32848 KB | Output is correct |
10 | Correct | 47 ms | 29776 KB | Output is correct |
11 | Correct | 88 ms | 45152 KB | Output is correct |
12 | Correct | 3 ms | 14524 KB | Output is correct |
13 | Correct | 3 ms | 14428 KB | Output is correct |
14 | Correct | 3 ms | 14428 KB | Output is correct |
15 | Correct | 3 ms | 14424 KB | Output is correct |
16 | Correct | 3 ms | 14428 KB | Output is correct |
17 | Correct | 3 ms | 14516 KB | Output is correct |
18 | Correct | 18 ms | 26968 KB | Output is correct |
19 | Correct | 18 ms | 26972 KB | Output is correct |
20 | Correct | 18 ms | 26968 KB | Output is correct |
21 | Correct | 17 ms | 26972 KB | Output is correct |
22 | Correct | 52 ms | 34896 KB | Output is correct |
23 | Correct | 87 ms | 45156 KB | Output is correct |
24 | Correct | 87 ms | 45728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 32196 KB | Output is correct |
2 | Correct | 48 ms | 34496 KB | Output is correct |
3 | Correct | 18 ms | 26972 KB | Output is correct |
4 | Correct | 19 ms | 26968 KB | Output is correct |
5 | Correct | 106 ms | 50604 KB | Output is correct |
6 | Correct | 120 ms | 56148 KB | Output is correct |
7 | Correct | 3 ms | 14424 KB | Output is correct |
8 | Correct | 69 ms | 37748 KB | Output is correct |
9 | Correct | 81 ms | 41912 KB | Output is correct |
10 | Correct | 40 ms | 32204 KB | Output is correct |
11 | Correct | 49 ms | 34496 KB | Output is correct |
12 | Correct | 3 ms | 14424 KB | Output is correct |
13 | Correct | 3 ms | 14428 KB | Output is correct |
14 | Correct | 3 ms | 14428 KB | Output is correct |
15 | Correct | 4 ms | 14428 KB | Output is correct |
16 | Correct | 18 ms | 26968 KB | Output is correct |
17 | Correct | 18 ms | 26972 KB | Output is correct |
18 | Correct | 52 ms | 32228 KB | Output is correct |
19 | Correct | 55 ms | 34512 KB | Output is correct |
20 | Correct | 42 ms | 31028 KB | Output is correct |
21 | Correct | 45 ms | 32700 KB | Output is correct |
22 | Correct | 41 ms | 30912 KB | Output is correct |
23 | Correct | 55 ms | 32704 KB | Output is correct |
24 | Correct | 19 ms | 26972 KB | Output is correct |
25 | Correct | 18 ms | 26992 KB | Output is correct |
26 | Correct | 34 ms | 28864 KB | Output is correct |
27 | Correct | 29 ms | 29016 KB | Output is correct |
28 | Correct | 52 ms | 32852 KB | Output is correct |
29 | Correct | 47 ms | 32340 KB | Output is correct |
30 | Correct | 52 ms | 32964 KB | Output is correct |
31 | Correct | 50 ms | 32848 KB | Output is correct |
32 | Correct | 3 ms | 14424 KB | Output is correct |
33 | Correct | 3 ms | 14592 KB | Output is correct |
34 | Correct | 3 ms | 14428 KB | Output is correct |
35 | Correct | 3 ms | 14428 KB | Output is correct |
36 | Correct | 3 ms | 14428 KB | Output is correct |
37 | Correct | 3 ms | 14428 KB | Output is correct |
38 | Correct | 3 ms | 14428 KB | Output is correct |
39 | Correct | 3 ms | 14428 KB | Output is correct |
40 | Correct | 3 ms | 14516 KB | Output is correct |
41 | Correct | 4 ms | 14684 KB | Output is correct |
42 | Correct | 3 ms | 14428 KB | Output is correct |
43 | Correct | 3 ms | 14424 KB | Output is correct |
44 | Correct | 3 ms | 14428 KB | Output is correct |
45 | Correct | 4 ms | 14428 KB | Output is correct |
46 | Correct | 3 ms | 14428 KB | Output is correct |
47 | Correct | 3 ms | 14684 KB | Output is correct |
48 | Correct | 14 ms | 18268 KB | Output is correct |
49 | Correct | 14 ms | 19676 KB | Output is correct |
50 | Correct | 14 ms | 19276 KB | Output is correct |
51 | Correct | 14 ms | 19400 KB | Output is correct |
52 | Correct | 14 ms | 19292 KB | Output is correct |
53 | Correct | 27 ms | 24148 KB | Output is correct |
54 | Correct | 5 ms | 15416 KB | Output is correct |
55 | Correct | 11 ms | 17096 KB | Output is correct |
56 | Correct | 3 ms | 14428 KB | Output is correct |
57 | Correct | 5 ms | 15164 KB | Output is correct |
58 | Correct | 4 ms | 14936 KB | Output is correct |
59 | Correct | 58 ms | 37460 KB | Output is correct |
60 | Correct | 84 ms | 42724 KB | Output is correct |
61 | Correct | 90 ms | 42356 KB | Output is correct |
62 | Correct | 85 ms | 42576 KB | Output is correct |
63 | Correct | 91 ms | 47700 KB | Output is correct |
64 | Correct | 91 ms | 42580 KB | Output is correct |
65 | Correct | 112 ms | 42432 KB | Output is correct |
66 | Correct | 35 ms | 26192 KB | Output is correct |
67 | Correct | 85 ms | 45924 KB | Output is correct |
68 | Correct | 55 ms | 32848 KB | Output is correct |
69 | Correct | 47 ms | 29776 KB | Output is correct |
70 | Correct | 88 ms | 45152 KB | Output is correct |
71 | Correct | 3 ms | 14524 KB | Output is correct |
72 | Correct | 3 ms | 14428 KB | Output is correct |
73 | Correct | 3 ms | 14428 KB | Output is correct |
74 | Correct | 3 ms | 14424 KB | Output is correct |
75 | Correct | 3 ms | 14428 KB | Output is correct |
76 | Correct | 3 ms | 14516 KB | Output is correct |
77 | Correct | 18 ms | 26968 KB | Output is correct |
78 | Correct | 18 ms | 26972 KB | Output is correct |
79 | Correct | 18 ms | 26968 KB | Output is correct |
80 | Correct | 17 ms | 26972 KB | Output is correct |
81 | Correct | 52 ms | 34896 KB | Output is correct |
82 | Correct | 87 ms | 45156 KB | Output is correct |
83 | Correct | 87 ms | 45728 KB | Output is correct |
84 | Correct | 109 ms | 51912 KB | Output is correct |
85 | Correct | 108 ms | 52644 KB | Output is correct |
86 | Correct | 122 ms | 52816 KB | Output is correct |
87 | Correct | 131 ms | 54096 KB | Output is correct |
88 | Correct | 4 ms | 14428 KB | Output is correct |
89 | Correct | 144 ms | 54100 KB | Output is correct |
90 | Correct | 118 ms | 54608 KB | Output is correct |
91 | Correct | 104 ms | 55376 KB | Output is correct |