#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
unordered_map<ll,ll> m, dp;
ll solve(int c, int p1, int p2){
if (c == n) return 0;
if (dp.find(c*100+(p1+1)*10+p2+1) != dp.end()) return dp[c*100+(p1+1)*10+p2+1];
ll cur = 0, res = 0;
for (int i=-1; i<1; ){
//if (c == 4 && p1 == -1 && p2 == -1) cout << i << " " << cur << "\n";
res = max(res, cur+solve(c+1, i, p1));
i++;
if (c > 0 && p1 < i && (c == 1 || p2 < i)) cur += m[(c-1)*9+i];
if (c < n-1) cur += m[(c+1)*9+i];
if (c > 0 && p1 >= i) cur -= m[c*9+i];
}
//cout << c << " " << p1 << " " << p2 << " " << res << "\n";
return dp[c*100+(p1+1)*10+p2+1] = res;
}
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
n = N;
for (int i=0; i<M; i++) m[X[i]*9+Y[i]] = W[i];
return solve(0, 0, 0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
43060 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '3589340622644' |
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: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
40356 KB |
Output is correct |
2 |
Correct |
58 ms |
40364 KB |
Output is correct |
3 |
Correct |
66 ms |
40392 KB |
Output is correct |
4 |
Correct |
64 ms |
41368 KB |
Output is correct |
5 |
Correct |
76 ms |
43068 KB |
Output is correct |
6 |
Correct |
80 ms |
43192 KB |
Output is correct |
7 |
Correct |
76 ms |
43060 KB |
Output is correct |
8 |
Correct |
81 ms |
43064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '1' |
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: '1' |
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: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
40356 KB |
Output is correct |
2 |
Correct |
58 ms |
40364 KB |
Output is correct |
3 |
Correct |
66 ms |
40392 KB |
Output is correct |
4 |
Correct |
64 ms |
41368 KB |
Output is correct |
5 |
Correct |
76 ms |
43068 KB |
Output is correct |
6 |
Correct |
80 ms |
43192 KB |
Output is correct |
7 |
Correct |
76 ms |
43060 KB |
Output is correct |
8 |
Correct |
81 ms |
43064 KB |
Output is correct |
9 |
Incorrect |
87 ms |
45364 KB |
1st lines differ - on the 1st token, expected: '99999', found: '10000' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
43060 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '3589340622644' |
2 |
Halted |
0 ms |
0 KB |
- |