#include "fish.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
const int N = 3003;
int n;
long long dp[N][N][2][2];
vector<vector<int>> a;
long long bt(int col, int last, bool me, bool recent) {
if (col > n) {
return 0;
}
if (last > n || last < 0) {
return -1e16;
}
long long& ret = dp[col][last][me][recent];
if (ret != -1) {
return ret;
}
if (me) {
ret = max(bt(col, last - 1, me, recent) + a[col][last],
bt(col + 1, last, me ^ (last == 0), (last == 0)));
} else {
ret = max(bt(col, last + 1, me, recent) + a[col - 1][last] * (recent == false),
bt(col + 1, last, me ^ (last == n), false));
};
return ret;
}
long long max_weights(int N_, int M, vector<int> X, vector<int> Y, vector<int> W) {
n = N_;
a.resize(n + 1);
for (int i = 0; i <= n; ++i) {
a[i].resize(n + 1);
}
for (int i = 0; i < M; ++i) {
a[X[i] + 1][Y[i] + 1] = W[i];
}
memset(dp, -1, sizeof dp);
return bt(1, 0, 0, 0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1165 ms |
1965848 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
282556 KB |
Output is correct |
2 |
Runtime error |
746 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
633 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
110 ms |
282540 KB |
Output is correct |
2 |
Correct |
111 ms |
282556 KB |
Output is correct |
3 |
Correct |
116 ms |
282572 KB |
Output is correct |
4 |
Correct |
111 ms |
282572 KB |
Output is correct |
5 |
Correct |
115 ms |
282704 KB |
Output is correct |
6 |
Correct |
111 ms |
282592 KB |
Output is correct |
7 |
Correct |
119 ms |
282540 KB |
Output is correct |
8 |
Correct |
116 ms |
282604 KB |
Output is correct |
9 |
Correct |
121 ms |
282700 KB |
Output is correct |
10 |
Correct |
119 ms |
283084 KB |
Output is correct |
11 |
Correct |
118 ms |
282756 KB |
Output is correct |
12 |
Correct |
114 ms |
283036 KB |
Output is correct |
13 |
Correct |
126 ms |
282580 KB |
Output is correct |
14 |
Correct |
117 ms |
283112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
110 ms |
282540 KB |
Output is correct |
2 |
Correct |
111 ms |
282556 KB |
Output is correct |
3 |
Correct |
116 ms |
282572 KB |
Output is correct |
4 |
Correct |
111 ms |
282572 KB |
Output is correct |
5 |
Correct |
115 ms |
282704 KB |
Output is correct |
6 |
Correct |
111 ms |
282592 KB |
Output is correct |
7 |
Correct |
119 ms |
282540 KB |
Output is correct |
8 |
Correct |
116 ms |
282604 KB |
Output is correct |
9 |
Correct |
121 ms |
282700 KB |
Output is correct |
10 |
Correct |
119 ms |
283084 KB |
Output is correct |
11 |
Correct |
118 ms |
282756 KB |
Output is correct |
12 |
Correct |
114 ms |
283036 KB |
Output is correct |
13 |
Correct |
126 ms |
282580 KB |
Output is correct |
14 |
Correct |
117 ms |
283112 KB |
Output is correct |
15 |
Correct |
113 ms |
283084 KB |
Output is correct |
16 |
Incorrect |
122 ms |
282736 KB |
1st lines differ - on the 1st token, expected: '741526820812', found: '737338803564' |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
110 ms |
282540 KB |
Output is correct |
2 |
Correct |
111 ms |
282556 KB |
Output is correct |
3 |
Correct |
116 ms |
282572 KB |
Output is correct |
4 |
Correct |
111 ms |
282572 KB |
Output is correct |
5 |
Correct |
115 ms |
282704 KB |
Output is correct |
6 |
Correct |
111 ms |
282592 KB |
Output is correct |
7 |
Correct |
119 ms |
282540 KB |
Output is correct |
8 |
Correct |
116 ms |
282604 KB |
Output is correct |
9 |
Correct |
121 ms |
282700 KB |
Output is correct |
10 |
Correct |
119 ms |
283084 KB |
Output is correct |
11 |
Correct |
118 ms |
282756 KB |
Output is correct |
12 |
Correct |
114 ms |
283036 KB |
Output is correct |
13 |
Correct |
126 ms |
282580 KB |
Output is correct |
14 |
Correct |
117 ms |
283112 KB |
Output is correct |
15 |
Correct |
113 ms |
283084 KB |
Output is correct |
16 |
Incorrect |
122 ms |
282736 KB |
1st lines differ - on the 1st token, expected: '741526820812', found: '737338803564' |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
633 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1165 ms |
1965848 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |