#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define NL '\n'
#define EL cout << NL
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define FORS(i,s,n) for(int i = (s); i < (n); i++)
#define PRINTV(v) for(auto a:v) {cout << a << " ";} EL;
#define PRINTVV(v) for(auto a:v) {PRINTV(a);}
#define f first
#define s second
#define all(v) (v).begin(),(v).end()
#define STRP(p) "{" << (p).f << "," << (p).s << "}"
#define PRINTVP(v) for(auto a:v) {cout << STRP(a) << " ";} EL;
#define PRINTVVP(v) for(auto a:v) {PRINTVP(a);}
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<vpl> vvpl;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
vvl a(N,vl(N));
FOR(i,M) {
a[X[i]][Y[i]] = W[i];
}
vvl dp_up(N,vl(N,-1e18));
vvl dp_down(N,vl(N,-1e18));
FOR(i,N) {
dp_up[i][0] = a[i][0];
}
FOR(i,N) {
FOR(j,N) {
if (j >= 1) {
dp_up[i][j] = max(dp_up[i][j],dp_up[i][j-1] + a[i][j]);
if (i >= 1) {
dp_up[i][j] = max(dp_up[i][j],dp_up[i-1][j-1] + a[i][j]);
}
}
FORS(k,i-6,i-1) {
if (k < 0) continue;
dp_up[i][j] = max(dp_up[i][j],dp_down[k][j] + a[i][j]);
}
}
FOR(_j,N) {
ll j = N-_j-1;
if (j < N-1) {
dp_down[i][j] = max(dp_down[i][j],dp_down[i][j+1] + a[i][j]);
if (i >= 1) {
dp_down[i][j] = max(dp_down[i][j],dp_down[i-1][j+1] + a[i][j]);
}
}
FORS(k,i-6,i-1) {
if (k < 0) continue;
dp_down[i][j] = max(dp_down[i][j],dp_up[k][j] + a[i][j]);
}
}
}
// PRINTVV(a); EL;
// FOR(_j,N) {
// ll j = N-_j-1;
// FOR(i,N) {
// cout << a[i][j] << " ";
// }
// EL;
// } EL;
// FOR(_j,N) {
// ll j = N-_j-1;
// FOR(i,N) {
// cout << dp_up[i][j] << " ";
// }
// EL;
// } EL;
// FOR(_j,N) {
// ll j = N-_j-1;
// FOR(i,N) {
// cout << dp_down[i][j] << " ";
// }
// EL;
// } EL;
ll ans = 0;
FOR(i,N-1) {
FOR(j,N) {
ans = max(ans,dp_up[i][j]);
}
}
FOR(i,N) {
FOR(j,N) {
ans = max(ans,dp_down[i][j]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1147 ms |
1903992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1125 ms |
2097152 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1165 ms |
2097152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
344 KB |
1st lines differ - on the 1st token, expected: '4044', found: '2022' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1165 ms |
2097152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1147 ms |
1903992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |