#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 |
673 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
669 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
17496 KB |
Output is correct |
2 |
Correct |
15 ms |
17500 KB |
Output is correct |
3 |
Correct |
30 ms |
19804 KB |
Output is correct |
4 |
Correct |
25 ms |
20052 KB |
Output is correct |
5 |
Correct |
42 ms |
24660 KB |
Output is correct |
6 |
Correct |
41 ms |
23892 KB |
Output is correct |
7 |
Correct |
41 ms |
24512 KB |
Output is correct |
8 |
Correct |
43 ms |
24660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '157486067342' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '157486067342' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
Incorrect |
1 ms |
348 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '157486067342' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
17496 KB |
Output is correct |
2 |
Correct |
15 ms |
17500 KB |
Output is correct |
3 |
Correct |
30 ms |
19804 KB |
Output is correct |
4 |
Correct |
25 ms |
20052 KB |
Output is correct |
5 |
Correct |
42 ms |
24660 KB |
Output is correct |
6 |
Correct |
41 ms |
23892 KB |
Output is correct |
7 |
Correct |
41 ms |
24512 KB |
Output is correct |
8 |
Correct |
43 ms |
24660 KB |
Output is correct |
9 |
Runtime error |
654 ms |
2097152 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
673 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |