#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define re resize
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define all1(x) (x).begin()+1, (x).end()
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, n) for(int i = 1; i <= n; i++)
#define print(x) cout << #x << ": " << x << endl << flush
template<class T> bool ckmin(T&a, T b) { bool B = a > b; a = min(a, b); return B; }
template<class T> bool ckmax(T&a, T b) { bool B = a < b; a = max(a, b); return B; }
typedef long long ll;
typedef vector<int> vi;
const ll inf = 1e17;
const ll maxn = 3005;
ll fish[maxn][maxn];
ll pref[maxn][maxn];
ll dpi[maxn][maxn];
ll dpd[maxn][maxn];
ll max_weights(int n, int m, vi x, vi y, vi w) {
loop(i, m) {
x[i]++; y[i]++;
fish[x[i]][y[i]] = w[i];
}
loop1(i, n) loop1(j, n)
pref[i][j] = pref[i][j-1] + fish[i][j];
loop(i, n+2) dpi[0][i] = -inf;
loop(i, n+2) dpd[0][i] = -inf;
dpd[0][0] = 0;
loop1(i, n+1) {
loop1(j, n) {
if(i >= 2) {
loop(k, n+1)
ckmax(dpi[i][j], dpd[i-2][k] + pref[i-1][max(j, k)] - pref[i-1][0]);
}
loop1(k, n) if(k <= j)
ckmax(dpi[i][j], dpi[i-1][k] + pref[i-1][j] - pref[i-1][k]);
}
loop(j, n+1) {
ckmax(dpd[i][j], dpi[i-1][n] + pref[i][n] - pref[i][j]);
loop(k, n+1) if(k >= j)
ckmax(dpd[i][j], dpd[i-1][k] + pref[i][k] - pref[i][j]);
}
}
return dpd[n+1][0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
807 ms |
150552 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Runtime error |
842 ms |
155852 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
883 ms |
143916 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
17 ms |
3260 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
17 ms |
3260 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
17 ms |
3260 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '214837477243' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
883 ms |
143916 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
807 ms |
150552 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |