#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
//unordered_map<ll,ll> dp;
vector<vector<vector<ll>>> dp;
vector<vector<ll>> v;
ll solve(int c, int p1, int p2){
//cout << c << " " << p1 << " " << p2 << "\n";
if (c == n) return 0;
if (dp[c][p1+1][p2+1] != -1) return dp[c][p1+1][p2+1];
ll cur = 0, res = 0;
for (int i=-1; i<min(n, 9); ){
//if (c == 4 && p1 == -1 && p2 == -1) cout << i << " " << cur << "\n";
res = max((ll) res, (ll) cur+ (ll) solve(c+1, i, p1));
i++;
if ((c > 0) && (p1 < i) && (c == 1 || p2 < i)) cur += v[c-1][i];
if (c < n-1) cur += v[c+1][i];
if ((c > 0) && (p1 >= i)) cur -= v[c][i];
}
//cout << c << " " << p1 << " " << p2 << " " << res << "\n";
return dp[c][p1+1][p2+1] = res;
}
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
n = N;
v.resize(N, vector<ll>(9, 0));
for (int i=0; i<M; i++) v[X[i]][Y[i]] = W[i];
dp.resize(n, vector<vector<ll>>(10, vector<ll>(10, -1)));
return solve(0, 0, 0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
714 ms |
264416 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
703 ms |
263220 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
631 ms |
144212 KB |
Output is correct |
2 |
Correct |
641 ms |
144456 KB |
Output is correct |
3 |
Correct |
594 ms |
131924 KB |
Output is correct |
4 |
Correct |
634 ms |
145816 KB |
Output is correct |
5 |
Correct |
652 ms |
148028 KB |
Output is correct |
6 |
Correct |
658 ms |
147668 KB |
Output is correct |
7 |
Correct |
682 ms |
147792 KB |
Output is correct |
8 |
Correct |
655 ms |
147988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
424 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
424 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
860 KB |
Output is correct |
15 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 6 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
424 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
860 KB |
Output is correct |
15 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 6 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
631 ms |
144212 KB |
Output is correct |
2 |
Correct |
641 ms |
144456 KB |
Output is correct |
3 |
Correct |
594 ms |
131924 KB |
Output is correct |
4 |
Correct |
634 ms |
145816 KB |
Output is correct |
5 |
Correct |
652 ms |
148028 KB |
Output is correct |
6 |
Correct |
658 ms |
147668 KB |
Output is correct |
7 |
Correct |
682 ms |
147792 KB |
Output is correct |
8 |
Correct |
655 ms |
147988 KB |
Output is correct |
9 |
Runtime error |
30 ms |
26972 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
714 ms |
264416 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |