# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
626626 | 2022-08-11T15:13:57 Z | ITO | Catfish Farm (IOI22_fish) | C++17 | 144 ms | 21820 KB |
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { vector<vector<pair<int, ll>>> v(N, vector<pair<int, ll>>(0)); vector<ll> ru[2], rd[2]; int p0 = 1, p1 = 0; ll co = 0; for (int i = 0; i < M; i++) { v[X[i]].push_back({Y[i], W[i]}); } for (int i = 0; i < N; i++) { v[i].push_back({0, 0}); v[i].push_back({N, 0}); sort(v[i].begin(), v[i].end()); for (int j = 1; j < v[i].size(); j++) v[i][j].second += v[i][j - 1].second; } for (int j = 0; j < v[0].size(); j++) { ru[0].push_back(0); rd[0].push_back(0); } for (int i = 1; i < N; i++) { ru[p0].clear(); rd[p0].clear(); int j, k = 1; ll te = ru[p1][0]; for (j = 0; j < v[i].size(); j++) { while (k < v[i - 1].size() && v[i - 1][k].first <= v[i][j].first) { te = max(te, ru[p1][k] - v[i - 1][k - 1].second); k++; } if (k >= 2 && v[i - 1][k - 1].first == v[i][j].first) { ru[p0].push_back(te + v[i - 1][k - 2].second); } else { ru[p0].push_back(te + v[i - 1][k - 1].second); } rd[p0].push_back(ru[p0].back()); } k = v[i - 1].size() - 2; te = rd[p1].back() + v[i].back().second; for (j = v[i].size() - 1; j > 0; j--) { while (k >= 0 && v[i - 1][k].first >= v[i][j].first) { if (v[i - 1][k].first > v[i][j].first) { te = max(te, rd[p1][k] + v[i][j].second); } else { te = max(te, rd[p1][k] + v[i][j - 1].second); } k--; } rd[p0][j] = max(rd[p0][j], te - v[i][j - 1].second); } while (k >= 0 && v[i - 1][k].first >= v[i][j].first) { te = max(te, rd[p1][k]); k--; } rd[p0][0] = max(rd[p0][0], te); ru[p0][0] = max(ru[p0][0], rd[p1][0]); swap(p0, p1); } for (int i = 0; i < ru[p1].size(); i++) co = max(co, max(ru[p1][i], rd[p1][i])); return co; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 12348 KB | Output is correct |
2 | Correct | 55 ms | 14260 KB | Output is correct |
3 | Correct | 15 ms | 7296 KB | Output is correct |
4 | Correct | 16 ms | 7340 KB | Output is correct |
5 | Correct | 127 ms | 21820 KB | Output is correct |
6 | Correct | 144 ms | 21748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 76 ms | 16836 KB | Output is correct |
3 | Correct | 91 ms | 19632 KB | Output is correct |
4 | Correct | 47 ms | 12364 KB | Output is correct |
5 | Correct | 52 ms | 14140 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 296 KB | Output is correct |
10 | Correct | 16 ms | 7240 KB | Output is correct |
11 | Correct | 15 ms | 7336 KB | Output is correct |
12 | Correct | 44 ms | 13880 KB | Output is correct |
13 | Correct | 56 ms | 15916 KB | Output is correct |
14 | Correct | 49 ms | 13536 KB | Output is correct |
15 | Correct | 54 ms | 14880 KB | Output is correct |
16 | Correct | 48 ms | 13496 KB | Output is correct |
17 | Correct | 58 ms | 14808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 7252 KB | Output is correct |
2 | Correct | 16 ms | 7224 KB | Output is correct |
3 | Incorrect | 41 ms | 10152 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '20897672610412' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Incorrect | 1 ms | 340 KB | 1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 7252 KB | Output is correct |
2 | Correct | 16 ms | 7224 KB | Output is correct |
3 | Incorrect | 41 ms | 10152 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '20897672610412' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 12348 KB | Output is correct |
2 | Correct | 55 ms | 14260 KB | Output is correct |
3 | Correct | 15 ms | 7296 KB | Output is correct |
4 | Correct | 16 ms | 7340 KB | Output is correct |
5 | Correct | 127 ms | 21820 KB | Output is correct |
6 | Correct | 144 ms | 21748 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 76 ms | 16836 KB | Output is correct |
9 | Correct | 91 ms | 19632 KB | Output is correct |
10 | Correct | 47 ms | 12364 KB | Output is correct |
11 | Correct | 52 ms | 14140 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 300 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 296 KB | Output is correct |
16 | Correct | 16 ms | 7240 KB | Output is correct |
17 | Correct | 15 ms | 7336 KB | Output is correct |
18 | Correct | 44 ms | 13880 KB | Output is correct |
19 | Correct | 56 ms | 15916 KB | Output is correct |
20 | Correct | 49 ms | 13536 KB | Output is correct |
21 | Correct | 54 ms | 14880 KB | Output is correct |
22 | Correct | 48 ms | 13496 KB | Output is correct |
23 | Correct | 58 ms | 14808 KB | Output is correct |
24 | Correct | 16 ms | 7252 KB | Output is correct |
25 | Correct | 16 ms | 7224 KB | Output is correct |
26 | Incorrect | 41 ms | 10152 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '20897672610412' |
27 | Halted | 0 ms | 0 KB | - |