#pragma GCC optimize("O3")
#include "fish.h"
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll INF = 3e14 + 4;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
ll dp[N][2], a[N];
memset(dp, 0, sizeof(dp)); memset(a, 0, sizeof(a));
for(int i = 0; i < M; i++) a[X[i]] += W[i];
dp[1][0] = a[1];
dp[1][1] = a[0];
for(int i = 2; i < N; i++){
dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0]);
dp[i][1] = max(max(dp[i - 2][0] + a[i - 1], dp[i - 1][1]), dp[i - 2][1] + a[i - 1]);
}
return max(dp[N - 1][0], dp[N - 1][1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
4172 KB |
Output is correct |
2 |
Correct |
27 ms |
4940 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2648 KB |
Output is correct |
5 |
Correct |
92 ms |
9588 KB |
Output is correct |
6 |
Correct |
100 ms |
9548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
14 ms |
3632 KB |
Output is correct |
4 |
Correct |
11 ms |
3412 KB |
Output is correct |
5 |
Correct |
29 ms |
4940 KB |
Output is correct |
6 |
Correct |
24 ms |
4948 KB |
Output is correct |
7 |
Correct |
27 ms |
4936 KB |
Output is correct |
8 |
Correct |
28 ms |
4940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
14 ms |
3632 KB |
Output is correct |
4 |
Correct |
11 ms |
3412 KB |
Output is correct |
5 |
Correct |
29 ms |
4940 KB |
Output is correct |
6 |
Correct |
24 ms |
4948 KB |
Output is correct |
7 |
Correct |
27 ms |
4936 KB |
Output is correct |
8 |
Correct |
28 ms |
4940 KB |
Output is correct |
9 |
Incorrect |
26 ms |
4944 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
4172 KB |
Output is correct |
2 |
Correct |
27 ms |
4940 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
3 ms |
2648 KB |
Output is correct |
5 |
Correct |
92 ms |
9588 KB |
Output is correct |
6 |
Correct |
100 ms |
9548 KB |
Output is correct |
7 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |