#include "fish.h"
#include "bits/stdc++.h";
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct pii{int a, b;};
ll INF = 1e16;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
int MH = Y[0] + 1;
for(int i : Y) MH = max(MH, i + 1);
vvll wp(N, vll(MH));
forR(i, M) wp[X[i]][Y[i]] = W[i];
vvll I(N, vll(MH+1)), D(N, vll(MH+1)), E(N, vll(MH+1));
// h = HEIGHT, not the index of last element!
forR(i, N) {
REP(h, 1, MH+1) {
if(i == 0) I[i][h] = 0;
else {
forR(k, MH+1) {
ll tot = E[i-1][k];
REP(y, k, h) tot += wp[i-1][y];
I[i][h] = max(I[i][h], tot);
}
REP(k, 1, h+1) {
ll tot = I[i-1][k];
REP(y, k, h) tot += wp[i-1][y];
I[i][h] = max(I[i][h], tot);
}
}
}
REP(h, 1, MH+1) {
if(i == 0) D[i][h] = 0;
else {
REP(k, h+1, MH+1) {
ll tot = max(I[i-1][k], D[i-1][k]);
REP(y, h, k) tot += wp[i][y];
D[i][h] = max(D[i][h], tot);
}
}
}
forR(h, MH+1) {
if(i == 0) E[i][h] = 0;
else {
ll tot = max(I[i-1][h], D[i-1][h]);
forR(y, h) tot += wp[i][y];
E[i][h] = max(E[i][h], tot);
forR(y, MH+1) E[i][h] = max(E[i][h], E[i-1][y]);
}
}
}
ll mx = 0;
REP(h, 1, MH+1) mx = max(mx, max(I[N-1][h], D[N-1][h]));
forR(h, MH+1) mx = max(mx, E[N-1][h]);
return mx;
}
Compilation message
fish.cpp:2:25: warning: extra tokens at end of #include directive
2 | #include "bits/stdc++.h";
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
696 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 |
723 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
22108 KB |
Output is correct |
2 |
Correct |
18 ms |
22204 KB |
Output is correct |
3 |
Correct |
24 ms |
21340 KB |
Output is correct |
4 |
Correct |
24 ms |
23636 KB |
Output is correct |
5 |
Correct |
33 ms |
26204 KB |
Output is correct |
6 |
Correct |
31 ms |
25628 KB |
Output is correct |
7 |
Correct |
33 ms |
26196 KB |
Output is correct |
8 |
Correct |
32 ms |
26192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Execution timed out |
1070 ms |
3164 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Execution timed out |
1070 ms |
3164 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
22108 KB |
Output is correct |
2 |
Correct |
18 ms |
22204 KB |
Output is correct |
3 |
Correct |
24 ms |
21340 KB |
Output is correct |
4 |
Correct |
24 ms |
23636 KB |
Output is correct |
5 |
Correct |
33 ms |
26204 KB |
Output is correct |
6 |
Correct |
31 ms |
25628 KB |
Output is correct |
7 |
Correct |
33 ms |
26196 KB |
Output is correct |
8 |
Correct |
32 ms |
26192 KB |
Output is correct |
9 |
Runtime error |
709 ms |
2097152 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
696 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |