#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN = 100005;
int n_col = 0;
const int max_height = 10;
long long dp[maxN][3][max_height];
long long prefix[maxN][max_height];
const long long INF = 1e18;
const int UP = 0;
const int DOWN = 1;
const int STOP = 2;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
n_col = N + 2;
for(int i = 0; i < M; i++) {
prefix[X[i] + 1][Y[i] + 1] = W[i];
}
for(int i = 0; i < n_col; i++) {
for(int j = 0; j < N; j++) {
prefix[i][j + 1] += prefix[i][j];
}
}
// for(int i = 0; i < n_col; i++) {
// for(int j = 0; j < prefix[i].size(); j++) {
// cout << prefix[i][j] << ' ';
// }
// cout<<'\n';
// }
for(int i = 0; i < n_col; i++) {
for(int j = 0; j < 3; j++) {
for(int k = 0; k <= max_height; k++) {
// printf("%d %d %d %lld\n", i, j, k, dp[i][j][k]);
if (i == 0) {
if (j != UP) {
dp[i][j][k] = -INF;
}
else {
dp[i][j][k] = prefix[0][k];
}
}
if (i == n_col - 1) break;
if (j == UP) {
for(int t = k; t <= N; t++) {
dp[i + 1][UP][t] = max(dp[i + 1][UP][t], dp[i][j][k] + prefix[i + 1][t] - prefix[i + 1][k]);
// printf("DEBUG: %d %d %lld\n",i, t, dp[i + 1][UP][t]);
}
dp[i + 1][STOP][k] = max(dp[i + 1][STOP][k], dp[i][j][k]);
}
else if(j == STOP) {
for(int t = 0; t <= k; t++){
dp[i + 1][DOWN][t] = max(dp[i + 1][DOWN][t], dp[i][j][k] + prefix[i + 1][k] - prefix[i + 1][t]);
}
}
else{
for(int t = 0; t <= k; t++) {
dp[i + 1][DOWN][t] = max(dp[i + 1][DOWN][t], dp[i][j][k] + prefix[i + 1][k] - prefix[i + 1][t]);
}
// down and immediately up
// maybe this case doesn't even exist...
for(int t = 0; t <= N; t++) {
const int height = max(t, k);
// printf("check: %d %d %lld % lld\n",i, t, dp[i][j][k], prefix[i + 1][height]);
dp[i + 1][UP][t] = max(dp[i + 1][UP][t], dp[i][j][k] + prefix[i + 1][height]);
// printf("DEBU2: %d %d %lld\n",i, t, dp[i + 1][UP][t]);
}
}
}
}
}
return dp[n_col - 1][DOWN][0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1089 ms |
4140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1085 ms |
6088 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1076 ms |
2272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
216 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: '9222394312139424885' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
216 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: '9222394312139424885' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
216 KB |
Output is correct |
5 |
Correct |
0 ms |
216 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: '9222394312139424885' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1076 ms |
2272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1089 ms |
4140 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |