# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
626659 | 2022-08-11T15:32:27 Z | ITO | 메기 농장 (IOI22_fish) | C++17 | 164 ms | 21816 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(max(ru[p0].back(), rd[p1][0])); } 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); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 66 ms | 12368 KB | Output is correct |
2 | Correct | 61 ms | 14132 KB | Output is correct |
3 | Correct | 16 ms | 7252 KB | Output is correct |
4 | Correct | 16 ms | 7252 KB | Output is correct |
5 | Correct | 162 ms | 21816 KB | Output is correct |
6 | Correct | 164 ms | 21628 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 94 ms | 16828 KB | Output is correct |
3 | Correct | 136 ms | 19756 KB | Output is correct |
4 | Correct | 46 ms | 12364 KB | Output is correct |
5 | Correct | 65 ms | 14116 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 16 ms | 7328 KB | Output is correct |
11 | Correct | 18 ms | 7348 KB | Output is correct |
12 | Correct | 47 ms | 12348 KB | Output is correct |
13 | Correct | 56 ms | 14212 KB | Output is correct |
14 | Correct | 50 ms | 12072 KB | Output is correct |
15 | Correct | 57 ms | 13220 KB | Output is correct |
16 | Correct | 58 ms | 12144 KB | Output is correct |
17 | Correct | 64 ms | 13296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 7252 KB | Output is correct |
2 | Correct | 23 ms | 7276 KB | Output is correct |
3 | Incorrect | 54 ms | 10076 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 280 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 256 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: '165092780656' |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 280 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 256 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: '165092780656' |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 280 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 256 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: '165092780656' |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 7252 KB | Output is correct |
2 | Correct | 23 ms | 7276 KB | Output is correct |
3 | Incorrect | 54 ms | 10076 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 66 ms | 12368 KB | Output is correct |
2 | Correct | 61 ms | 14132 KB | Output is correct |
3 | Correct | 16 ms | 7252 KB | Output is correct |
4 | Correct | 16 ms | 7252 KB | Output is correct |
5 | Correct | 162 ms | 21816 KB | Output is correct |
6 | Correct | 164 ms | 21628 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 94 ms | 16828 KB | Output is correct |
9 | Correct | 136 ms | 19756 KB | Output is correct |
10 | Correct | 46 ms | 12364 KB | Output is correct |
11 | Correct | 65 ms | 14116 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 16 ms | 7328 KB | Output is correct |
17 | Correct | 18 ms | 7348 KB | Output is correct |
18 | Correct | 47 ms | 12348 KB | Output is correct |
19 | Correct | 56 ms | 14212 KB | Output is correct |
20 | Correct | 50 ms | 12072 KB | Output is correct |
21 | Correct | 57 ms | 13220 KB | Output is correct |
22 | Correct | 58 ms | 12144 KB | Output is correct |
23 | Correct | 64 ms | 13296 KB | Output is correct |
24 | Correct | 22 ms | 7252 KB | Output is correct |
25 | Correct | 23 ms | 7276 KB | Output is correct |
26 | Incorrect | 54 ms | 10076 KB | 1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
27 | Halted | 0 ms | 0 KB | - |