#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) {
ll 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
683 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
700 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
17496 KB |
Output is correct |
2 |
Correct |
15 ms |
17500 KB |
Output is correct |
3 |
Correct |
29 ms |
19800 KB |
Output is correct |
4 |
Correct |
25 ms |
20108 KB |
Output is correct |
5 |
Correct |
45 ms |
24668 KB |
Output is correct |
6 |
Correct |
40 ms |
23900 KB |
Output is correct |
7 |
Correct |
52 ms |
24664 KB |
Output is correct |
8 |
Correct |
42 ms |
24648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
384 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 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
9 ms |
840 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
384 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 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
9 ms |
840 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Execution timed out |
1074 ms |
216700 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
384 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 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
9 ms |
840 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Execution timed out |
1074 ms |
216700 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
17496 KB |
Output is correct |
2 |
Correct |
15 ms |
17500 KB |
Output is correct |
3 |
Correct |
29 ms |
19800 KB |
Output is correct |
4 |
Correct |
25 ms |
20108 KB |
Output is correct |
5 |
Correct |
45 ms |
24668 KB |
Output is correct |
6 |
Correct |
40 ms |
23900 KB |
Output is correct |
7 |
Correct |
52 ms |
24664 KB |
Output is correct |
8 |
Correct |
42 ms |
24648 KB |
Output is correct |
9 |
Runtime error |
693 ms |
2097152 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
683 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |