#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
ll max_weights(int n, int m, vi X, vi Y, vi W) {
vll S(n + 1, 0);
for(int i = 0; i < m; ++i) {
S[X[i]] += W[i];
}
vector<vll> DP(n + 1, vll(3, 0));
for(int i = 0; i < n; ++i) {
for(int j = 0; j < 2; ++j) {
DP[i + 1][j + 1] = max(DP[i + 1][j + 1], DP[i][j]); /// nu fac nimic
}
///ult pier la i - 1 - j, acum construim la i => distanta 1 + j
DP[i + 1][0] = max(DP[i + 1][0], DP[i][0] - S[i] + S[i + 1]);
DP[i + 1][0] = max(DP[i + 1][0], DP[i][1] + S[i + 1]);
ll uv = S[i + 1];
if(i) uv += S[i - 1];
DP[i + 1][0] = max(DP[i + 1][0], DP[i][2] + uv);
}
ll re = 0;
for(auto it : DP[n]) re = max(re, it);
return re;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
9308 KB |
Output is correct |
2 |
Correct |
18 ms |
10588 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
4 ms |
6492 KB |
Output is correct |
5 |
Correct |
49 ms |
19944 KB |
Output is correct |
6 |
Correct |
49 ms |
20328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
6716 KB |
Output is correct |
2 |
Correct |
4 ms |
6492 KB |
Output is correct |
3 |
Correct |
17 ms |
8024 KB |
Output is correct |
4 |
Correct |
9 ms |
8028 KB |
Output is correct |
5 |
Correct |
18 ms |
10572 KB |
Output is correct |
6 |
Correct |
15 ms |
9820 KB |
Output is correct |
7 |
Correct |
17 ms |
10600 KB |
Output is correct |
8 |
Correct |
20 ms |
10588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
6716 KB |
Output is correct |
2 |
Correct |
4 ms |
6492 KB |
Output is correct |
3 |
Correct |
17 ms |
8024 KB |
Output is correct |
4 |
Correct |
9 ms |
8028 KB |
Output is correct |
5 |
Correct |
18 ms |
10572 KB |
Output is correct |
6 |
Correct |
15 ms |
9820 KB |
Output is correct |
7 |
Correct |
17 ms |
10600 KB |
Output is correct |
8 |
Correct |
20 ms |
10588 KB |
Output is correct |
9 |
Incorrect |
17 ms |
10332 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
9308 KB |
Output is correct |
2 |
Correct |
18 ms |
10588 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
4 ms |
6492 KB |
Output is correct |
5 |
Correct |
49 ms |
19944 KB |
Output is correct |
6 |
Correct |
49 ms |
20328 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |