# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828167 | 2023-08-17T06:14:34 Z | Amylopectin | Catfish Farm (IOI22_fish) | C++17 | 290 ms | 93864 KB |
#include "fish.h" #include <stdio.h> #include <iostream> #include <vector> #include <algorithm> using namespace std; const long long mxn = 1e6 + 10; struct we { long long hei,wei; }; struct sdp { long long al,alnr,lowe,acal,acalnr,aclowe; }; bool cmp(const struct we &l,const struct we &r) { return l.hei < r.hei; } vector<struct sdp> dp[mxn] = {}; vector<struct we> fil[mxn] = {}; long long n,m; long long max_weights(int N, int M, std::vector<int> cc , std::vector<int> rr,std::vector<int> ww) { long long i,j,cn,cm,fn,fm,rul,rur,vce,val,var,rul2; n = N; m = M; for(i=0; i<m; i++) { dp[cc[i]].push_back({0,0,0,0,0,0}); fil[cc[i]].push_back({rr[i],ww[i]}); } for(i=0; i<n; i++) { fil[i].push_back({n+2,0}); dp[i].push_back({0,0,0,0,0,0}); // fil[i].push_back({-1,0}); // dp[cc[i]].push_back({0,0,0,0,0,0}); sort(fil[i].begin(),fil[i].end(),cmp); } for(i=0; i<n; i++) { rul = 0; rur = 0; vce = 0; val = 0; var = 0; rul2 = 0; for(j=0; j<fil[i].size(); j++) { if(i > 0) while(fil[i-1][rul].hei < fil[i][j].hei) { val += fil[i-1][rul].wei; rul ++; } if(i>1) while(fil[i-2][rul2].hei < fil[i][j].hei) { rul2 ++; } while(i<n-1 && fil[i+1][rur].hei < fil[i][j].hei) { var += fil[i+1][rur].wei; rur ++; } if(rul2 > 0 && i>1) { dp[i][j].lowe = dp[i-2][rul2-1].acalnr + val; // dp[i][j].alnr = dp[i-2][rul2-1].acalnr + val; } if(i>1) dp[i][j].lowe = max(dp[i][j].lowe,dp[i-2][dp[i-2].size()-1].acal); // dp[i][j].alnr = max(dp[i][j].alnr,dp[i-2][dp[i-2].size()-1].acal); if(rul > 0 && i>0) { dp[i][j].lowe = max(dp[i][j].lowe,dp[i-1][rul-1].aclowe + val); } if(i>0) dp[i][j].alnr = max(dp[i][j].lowe,dp[i-1][dp[i-1].size()-1].acal - vce); dp[i][j].al = dp[i][j].alnr + var; if(j > 0) { dp[i][j].acal = max(dp[i][j].al,dp[i][j-1].acal); dp[i][j].acalnr = max(dp[i][j].alnr,dp[i][j-1].acalnr); dp[i][j].aclowe = max(dp[i][j].lowe - vce,dp[i][j-1].aclowe); } else { dp[i][j].acal = dp[i][j].al; dp[i][j].acalnr = dp[i][j].alnr; dp[i][j].aclowe = dp[i][j].lowe - vce; } vce += fil[i][j].wei; } } return dp[n-1][dp[n-1].size()-1].acalnr; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 64056 KB | Output is correct |
2 | Correct | 68 ms | 67020 KB | Output is correct |
3 | Correct | 32 ms | 56640 KB | Output is correct |
4 | Correct | 32 ms | 56604 KB | Output is correct |
5 | Correct | 148 ms | 85352 KB | Output is correct |
6 | Correct | 190 ms | 92588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 47188 KB | Output is correct |
2 | Correct | 89 ms | 72588 KB | Output is correct |
3 | Correct | 104 ms | 76588 KB | Output is correct |
4 | Correct | 61 ms | 63992 KB | Output is correct |
5 | Correct | 67 ms | 67020 KB | Output is correct |
6 | Correct | 21 ms | 47204 KB | Output is correct |
7 | Correct | 23 ms | 47268 KB | Output is correct |
8 | Correct | 22 ms | 47272 KB | Output is correct |
9 | Correct | 21 ms | 47152 KB | Output is correct |
10 | Correct | 32 ms | 56576 KB | Output is correct |
11 | Correct | 31 ms | 56572 KB | Output is correct |
12 | Correct | 60 ms | 64116 KB | Output is correct |
13 | Correct | 67 ms | 67016 KB | Output is correct |
14 | Correct | 60 ms | 64072 KB | Output is correct |
15 | Correct | 68 ms | 66484 KB | Output is correct |
16 | Correct | 61 ms | 64548 KB | Output is correct |
17 | Correct | 65 ms | 65968 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 56556 KB | Output is correct |
2 | Correct | 34 ms | 56584 KB | Output is correct |
3 | Correct | 65 ms | 61260 KB | Output is correct |
4 | Correct | 52 ms | 60352 KB | Output is correct |
5 | Correct | 89 ms | 68300 KB | Output is correct |
6 | Correct | 83 ms | 67536 KB | Output is correct |
7 | Correct | 97 ms | 68084 KB | Output is correct |
8 | Correct | 92 ms | 68140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 47248 KB | Output is correct |
2 | Correct | 20 ms | 47188 KB | Output is correct |
3 | Correct | 20 ms | 47240 KB | Output is correct |
4 | Correct | 21 ms | 47192 KB | Output is correct |
5 | Correct | 20 ms | 47188 KB | Output is correct |
6 | Correct | 21 ms | 47156 KB | Output is correct |
7 | Correct | 20 ms | 47188 KB | Output is correct |
8 | Correct | 21 ms | 47260 KB | Output is correct |
9 | Correct | 21 ms | 47328 KB | Output is correct |
10 | Correct | 23 ms | 47656 KB | Output is correct |
11 | Correct | 21 ms | 47312 KB | Output is correct |
12 | Correct | 21 ms | 47444 KB | Output is correct |
13 | Correct | 20 ms | 47188 KB | Output is correct |
14 | Correct | 20 ms | 47400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 47248 KB | Output is correct |
2 | Correct | 20 ms | 47188 KB | Output is correct |
3 | Correct | 20 ms | 47240 KB | Output is correct |
4 | Correct | 21 ms | 47192 KB | Output is correct |
5 | Correct | 20 ms | 47188 KB | Output is correct |
6 | Correct | 21 ms | 47156 KB | Output is correct |
7 | Correct | 20 ms | 47188 KB | Output is correct |
8 | Correct | 21 ms | 47260 KB | Output is correct |
9 | Correct | 21 ms | 47328 KB | Output is correct |
10 | Correct | 23 ms | 47656 KB | Output is correct |
11 | Correct | 21 ms | 47312 KB | Output is correct |
12 | Correct | 21 ms | 47444 KB | Output is correct |
13 | Correct | 20 ms | 47188 KB | Output is correct |
14 | Correct | 20 ms | 47400 KB | Output is correct |
15 | Correct | 20 ms | 47312 KB | Output is correct |
16 | Correct | 21 ms | 47460 KB | Output is correct |
17 | Correct | 36 ms | 52684 KB | Output is correct |
18 | Correct | 44 ms | 54244 KB | Output is correct |
19 | Correct | 36 ms | 54612 KB | Output is correct |
20 | Correct | 35 ms | 54568 KB | Output is correct |
21 | Correct | 35 ms | 54528 KB | Output is correct |
22 | Correct | 70 ms | 60700 KB | Output is correct |
23 | Correct | 36 ms | 48596 KB | Output is correct |
24 | Correct | 35 ms | 51288 KB | Output is correct |
25 | Correct | 29 ms | 47348 KB | Output is correct |
26 | Correct | 25 ms | 48396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 47248 KB | Output is correct |
2 | Correct | 20 ms | 47188 KB | Output is correct |
3 | Correct | 20 ms | 47240 KB | Output is correct |
4 | Correct | 21 ms | 47192 KB | Output is correct |
5 | Correct | 20 ms | 47188 KB | Output is correct |
6 | Correct | 21 ms | 47156 KB | Output is correct |
7 | Correct | 20 ms | 47188 KB | Output is correct |
8 | Correct | 21 ms | 47260 KB | Output is correct |
9 | Correct | 21 ms | 47328 KB | Output is correct |
10 | Correct | 23 ms | 47656 KB | Output is correct |
11 | Correct | 21 ms | 47312 KB | Output is correct |
12 | Correct | 21 ms | 47444 KB | Output is correct |
13 | Correct | 20 ms | 47188 KB | Output is correct |
14 | Correct | 20 ms | 47400 KB | Output is correct |
15 | Correct | 20 ms | 47312 KB | Output is correct |
16 | Correct | 21 ms | 47460 KB | Output is correct |
17 | Correct | 36 ms | 52684 KB | Output is correct |
18 | Correct | 44 ms | 54244 KB | Output is correct |
19 | Correct | 36 ms | 54612 KB | Output is correct |
20 | Correct | 35 ms | 54568 KB | Output is correct |
21 | Correct | 35 ms | 54528 KB | Output is correct |
22 | Correct | 70 ms | 60700 KB | Output is correct |
23 | Correct | 36 ms | 48596 KB | Output is correct |
24 | Correct | 35 ms | 51288 KB | Output is correct |
25 | Correct | 29 ms | 47348 KB | Output is correct |
26 | Correct | 25 ms | 48396 KB | Output is correct |
27 | Correct | 22 ms | 47856 KB | Output is correct |
28 | Correct | 107 ms | 77516 KB | Output is correct |
29 | Correct | 136 ms | 86308 KB | Output is correct |
30 | Correct | 135 ms | 85292 KB | Output is correct |
31 | Correct | 147 ms | 85168 KB | Output is correct |
32 | Correct | 137 ms | 90700 KB | Output is correct |
33 | Correct | 147 ms | 85212 KB | Output is correct |
34 | Correct | 157 ms | 85188 KB | Output is correct |
35 | Correct | 74 ms | 64836 KB | Output is correct |
36 | Correct | 150 ms | 88336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 56556 KB | Output is correct |
2 | Correct | 34 ms | 56584 KB | Output is correct |
3 | Correct | 65 ms | 61260 KB | Output is correct |
4 | Correct | 52 ms | 60352 KB | Output is correct |
5 | Correct | 89 ms | 68300 KB | Output is correct |
6 | Correct | 83 ms | 67536 KB | Output is correct |
7 | Correct | 97 ms | 68084 KB | Output is correct |
8 | Correct | 92 ms | 68140 KB | Output is correct |
9 | Correct | 97 ms | 67876 KB | Output is correct |
10 | Correct | 90 ms | 67360 KB | Output is correct |
11 | Correct | 177 ms | 86848 KB | Output is correct |
12 | Correct | 24 ms | 47256 KB | Output is correct |
13 | Correct | 29 ms | 47224 KB | Output is correct |
14 | Correct | 20 ms | 47220 KB | Output is correct |
15 | Correct | 24 ms | 47180 KB | Output is correct |
16 | Correct | 21 ms | 47244 KB | Output is correct |
17 | Correct | 19 ms | 47188 KB | Output is correct |
18 | Correct | 31 ms | 56584 KB | Output is correct |
19 | Correct | 31 ms | 56608 KB | Output is correct |
20 | Correct | 30 ms | 56620 KB | Output is correct |
21 | Correct | 37 ms | 56588 KB | Output is correct |
22 | Correct | 96 ms | 69404 KB | Output is correct |
23 | Correct | 196 ms | 86876 KB | Output is correct |
24 | Correct | 190 ms | 86860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 61 ms | 64056 KB | Output is correct |
2 | Correct | 68 ms | 67020 KB | Output is correct |
3 | Correct | 32 ms | 56640 KB | Output is correct |
4 | Correct | 32 ms | 56604 KB | Output is correct |
5 | Correct | 148 ms | 85352 KB | Output is correct |
6 | Correct | 190 ms | 92588 KB | Output is correct |
7 | Correct | 20 ms | 47188 KB | Output is correct |
8 | Correct | 89 ms | 72588 KB | Output is correct |
9 | Correct | 104 ms | 76588 KB | Output is correct |
10 | Correct | 61 ms | 63992 KB | Output is correct |
11 | Correct | 67 ms | 67020 KB | Output is correct |
12 | Correct | 21 ms | 47204 KB | Output is correct |
13 | Correct | 23 ms | 47268 KB | Output is correct |
14 | Correct | 22 ms | 47272 KB | Output is correct |
15 | Correct | 21 ms | 47152 KB | Output is correct |
16 | Correct | 32 ms | 56576 KB | Output is correct |
17 | Correct | 31 ms | 56572 KB | Output is correct |
18 | Correct | 60 ms | 64116 KB | Output is correct |
19 | Correct | 67 ms | 67016 KB | Output is correct |
20 | Correct | 60 ms | 64072 KB | Output is correct |
21 | Correct | 68 ms | 66484 KB | Output is correct |
22 | Correct | 61 ms | 64548 KB | Output is correct |
23 | Correct | 65 ms | 65968 KB | Output is correct |
24 | Correct | 32 ms | 56556 KB | Output is correct |
25 | Correct | 34 ms | 56584 KB | Output is correct |
26 | Correct | 65 ms | 61260 KB | Output is correct |
27 | Correct | 52 ms | 60352 KB | Output is correct |
28 | Correct | 89 ms | 68300 KB | Output is correct |
29 | Correct | 83 ms | 67536 KB | Output is correct |
30 | Correct | 97 ms | 68084 KB | Output is correct |
31 | Correct | 92 ms | 68140 KB | Output is correct |
32 | Correct | 21 ms | 47248 KB | Output is correct |
33 | Correct | 20 ms | 47188 KB | Output is correct |
34 | Correct | 20 ms | 47240 KB | Output is correct |
35 | Correct | 21 ms | 47192 KB | Output is correct |
36 | Correct | 20 ms | 47188 KB | Output is correct |
37 | Correct | 21 ms | 47156 KB | Output is correct |
38 | Correct | 20 ms | 47188 KB | Output is correct |
39 | Correct | 21 ms | 47260 KB | Output is correct |
40 | Correct | 21 ms | 47328 KB | Output is correct |
41 | Correct | 23 ms | 47656 KB | Output is correct |
42 | Correct | 21 ms | 47312 KB | Output is correct |
43 | Correct | 21 ms | 47444 KB | Output is correct |
44 | Correct | 20 ms | 47188 KB | Output is correct |
45 | Correct | 20 ms | 47400 KB | Output is correct |
46 | Correct | 20 ms | 47312 KB | Output is correct |
47 | Correct | 21 ms | 47460 KB | Output is correct |
48 | Correct | 36 ms | 52684 KB | Output is correct |
49 | Correct | 44 ms | 54244 KB | Output is correct |
50 | Correct | 36 ms | 54612 KB | Output is correct |
51 | Correct | 35 ms | 54568 KB | Output is correct |
52 | Correct | 35 ms | 54528 KB | Output is correct |
53 | Correct | 70 ms | 60700 KB | Output is correct |
54 | Correct | 36 ms | 48596 KB | Output is correct |
55 | Correct | 35 ms | 51288 KB | Output is correct |
56 | Correct | 29 ms | 47348 KB | Output is correct |
57 | Correct | 25 ms | 48396 KB | Output is correct |
58 | Correct | 22 ms | 47856 KB | Output is correct |
59 | Correct | 107 ms | 77516 KB | Output is correct |
60 | Correct | 136 ms | 86308 KB | Output is correct |
61 | Correct | 135 ms | 85292 KB | Output is correct |
62 | Correct | 147 ms | 85168 KB | Output is correct |
63 | Correct | 137 ms | 90700 KB | Output is correct |
64 | Correct | 147 ms | 85212 KB | Output is correct |
65 | Correct | 157 ms | 85188 KB | Output is correct |
66 | Correct | 74 ms | 64836 KB | Output is correct |
67 | Correct | 150 ms | 88336 KB | Output is correct |
68 | Correct | 97 ms | 67876 KB | Output is correct |
69 | Correct | 90 ms | 67360 KB | Output is correct |
70 | Correct | 177 ms | 86848 KB | Output is correct |
71 | Correct | 24 ms | 47256 KB | Output is correct |
72 | Correct | 29 ms | 47224 KB | Output is correct |
73 | Correct | 20 ms | 47220 KB | Output is correct |
74 | Correct | 24 ms | 47180 KB | Output is correct |
75 | Correct | 21 ms | 47244 KB | Output is correct |
76 | Correct | 19 ms | 47188 KB | Output is correct |
77 | Correct | 31 ms | 56584 KB | Output is correct |
78 | Correct | 31 ms | 56608 KB | Output is correct |
79 | Correct | 30 ms | 56620 KB | Output is correct |
80 | Correct | 37 ms | 56588 KB | Output is correct |
81 | Correct | 96 ms | 69404 KB | Output is correct |
82 | Correct | 196 ms | 86876 KB | Output is correct |
83 | Correct | 190 ms | 86860 KB | Output is correct |
84 | Correct | 170 ms | 86028 KB | Output is correct |
85 | Correct | 179 ms | 86644 KB | Output is correct |
86 | Correct | 246 ms | 92228 KB | Output is correct |
87 | Correct | 254 ms | 93072 KB | Output is correct |
88 | Correct | 28 ms | 47164 KB | Output is correct |
89 | Correct | 290 ms | 93132 KB | Output is correct |
90 | Correct | 238 ms | 93132 KB | Output is correct |
91 | Correct | 180 ms | 93864 KB | Output is correct |