#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
struct AIB {
int n;
vll V;
AIB(int N) : n(N + 2), V(N + 2, 0) {}
void update(int p, ll v) {
++p;
while(p < n) {
V[p] = max(V[p], v);
p += p & -p;
}
}
ll query(int p) {
++p;
ll re = 0;
if(p < 0) return 0;
while(p) {
re = max(re, V[p]);
p -= p & -p;
}
return re;
}
};
struct maxSuf {
int n;
AIB A;
maxSuf(int N) : n(N), A(N) {}
void update(int p, ll v) { A.update(n - p - 1, v); }
ll query(int p) { return A.query(n - p - 1); }
};
ll max_weights(int n, int m, vi X, vi Y, vi W) {
vector<vi> P(n);
for(int i = 0; i < m; ++i)
P[X[i]].push_back(i);
int hm = 0;
for(auto it : Y) hm = max(hm, it + 1);
vector<vector<vll>> DP(n + 1, vector(hm + 1, vll(hm + 1, 0ll)));
ll re = 0;
for(int i = 0; i < n; ++i) {
for(int h1 = 0; h1 < hm; ++h1) {
for(int h2 = 0; h2 < hm; ++h2) {
for(int h3 = 0; h3 < hm; ++h3) {
int delta = 0;
if(i) {
for(auto it : P[i - 1]) {
int y = Y[it];
if(y >= h2 && y >= h1 && y < h3) delta += W[it];
}
}
for(auto it : P[i]) {
int y = Y[it];
if(y < h2 && y < h3) delta -= W[it];
}
if(i + 1 < n) {
for(auto it : P[i + 1]) {
int y = Y[it];
if(y < h3) delta += W[it];
}
}
DP[i + 1][h2][h3] = max(DP[i + 1][h2][h3], DP[i][h1][h2] + delta);
re = max(re, DP[i + 1][h2][h3]);
}
}
}
}
return re;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
666 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 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 |
Incorrect |
14 ms |
17496 KB |
1st lines differ - on the 1st token, expected: '10082010', found: '0' |
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: '2' |
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: '2' |
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: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
17496 KB |
1st lines differ - on the 1st token, expected: '10082010', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
666 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |