# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
837931 | 2023-08-25T20:35:10 Z | joylintp | Catfish Farm (IOI22_fish) | C++17 | 1000 ms | 2097152 KB |
#include "fish.h" #include <bits/stdc++.h> using namespace std; long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { vector<vector<pair<int, int>>> fish(N); for (int i = 0; i < M; i++) fish[X[i]].push_back(make_pair(Y[i], W[i])); for (int i = 0; i < N; i++) sort(fish[i].begin(), fish[i].end()); vector<vector<vector<long long>>> dp(N - 1, vector<vector<long long>>(N + 1, vector<long long>(N + 1))); for (int x = 0; x <= N; x++) { int fid = 0; for (int y = 1; y <= N; y++) { dp[0][x][y] = dp[0][x][y - 1]; if (fid < fish[0].size() && fish[0][fid].first + 1 == y) { if (fish[0][fid].first >= x) dp[0][x][y] += fish[0][fid].second; fid++; } } } for (int i = 1; i < N - 1; i++) for (int x = 0; x <= N; x++) { for (int j = 0; j <= N; j++) dp[i][x][0] = max(dp[i][x][0], dp[i - 1][j][x]); int fid = 0; for (int y = 1; y <= N; y++) { dp[i][x][y] = dp[i][x][y - 1]; if (fid < fish[i].size() && fish[i][fid].first + 1 == y) { if (fish[i][fid].first >= x) dp[i][x][y] += fish[i][fid].second; fid++; } } } long long ret = 0; for (int x = 0; x <= N; x++) { long long now = 0; for (auto &p : fish[N - 1]) if (p.first >= x) break; else now += p.second; int fid = 0; for (int y = 0; y <= N; y++) { if (fid < fish[N - 1].size() && fish[N - 1][fid].first + 1 == y && y < x + 1) now -= fish[N - 1][fid].second; ret = max(ret, dp[N - 2][x][y] + now); } } /*for (int i = 0; i < N - 1; i++, cout << '\n') for (int j = 0; j <= N; j++, cout << '\n') for (int k = 0; k <= N; k++) cout << dp[i][j][k] << ' ';*/ return ret; } /* int main() { int N, M; cin >> N >> M; vector<int> X(M), Y(M), W(M); for (int i = 0; i < M; i++) cin >> X[i] >> Y[i] >> W[i]; cout << max_weights(N, M, X, Y, W) << '\n'; } */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1154 ms | 1894072 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 855 ms | 2097152 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 668 ms | 2097152 KB | Execution killed with signal 9 |
2 | 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 | 0 ms | 212 KB | Output is correct |
8 | Incorrect | 0 ms | 212 KB | 1st lines differ - on the 1st token, expected: '2', found: '1' |
9 | 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 | 0 ms | 212 KB | Output is correct |
8 | Incorrect | 0 ms | 212 KB | 1st lines differ - on the 1st token, expected: '2', found: '1' |
9 | 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 | 0 ms | 212 KB | Output is correct |
8 | Incorrect | 0 ms | 212 KB | 1st lines differ - on the 1st token, expected: '2', found: '1' |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 668 ms | 2097152 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1154 ms | 1894072 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |