# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1073288 |
2024-08-24T11:53:20 Z |
Zicrus |
Catfish Farm (IOI22_fish) |
C++17 |
|
814 ms |
2097152 KB |
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
typedef long long ll;
int n, m;
vector<int> x, y, w;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N; m = M; x = X; y = Y; w = W;
vector<vector<ll>> a(n, vector<ll>(n));
for (int i = 0; i < m; i++) {
a[x[i]][y[i]] = w[i];
}
vector<vector<ll>> dp(n, vector<ll>(n));
// TODO: 0-2
for (int j = 0; j <= min(n, 10); j++) { // i = 1
ll val = 0;
for (int k = 0; k < j; k++) {
val += a[0][k];
}
dp[1][j] = max(dp[1][j], val);
}
for (int j = 0; j <= min(n, 10); j++) { // i = 2
for (int j1 = 0; j1 <= j; j1++) {
for (int j2 = 0; j2 <= j; j2++) {
ll val = 0;
for (int k = j2; k < max(0, j1); k++) {
val += a[0][k];
}
for (int k = j1; k < max(j2, j); k++) {
val += a[1][k];
}
dp[2][j] = max(dp[2][j], val);
}
}
}
for (int i = 3; i < n; i++) {
for (int j = 0; j <= min(n, 10); j++) {
for (int j1 = 0; j1 <= j; j1++) {
for (int j2 = 0; j2 <= j; j2++) {
for (int j3 = 0; j3 <= j; j3++) {
ll val = dp[i-3][j3];
for (int k = j2; k < max(j3, j1); k++) {
val += a[i-2][k];
}
for (int k = j1; k < max(j2, j); k++) {
val += a[i-1][k];
}
dp[i][j] = max(dp[i][j], val);
}
}
}
}
}
ll res = 0;
for (int j = 0; j <= min(n, 10); j++) {
res = max(res, dp[n-1][j]);
}
for (int i = n-2; i >= n-5 && i >= 0; i--) {
for (int j = 0; j <= min(n, 10); j++) {
ll val = dp[i][j];
for (int k = 0; k < j; k++) {
val += a[i+1][k];
}
res = max(res, val);
}
}
return res;
}
#ifdef TEST
#include "grader.cpp"
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
762 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '58593' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
814 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
814 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
762 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |