#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
ll sum[N]{};
for (int i = 0;i<M;i++){
sum[X[i]]+=W[i]*1ll;
}
ll dp[N][2];
// memset(dp, 0, sizeof(dp));
dp[0][0] = 0;
dp[0][1] = sum[0];
ll ans = dp[0][1];
for (int i = 1;i<N;i++){
dp[i][0] = max(dp[i-1][1], dp[i-1][0]);
dp[i][1] = dp[i-1][0]+sum[i];
ans = max(ans, max(dp[i][0], dp[i][1]));
}
for (int i = 0;i<N;i++) assert(sum[i]<=ans);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4172 KB |
Output is correct |
2 |
Correct |
27 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
101 ms |
9568 KB |
Output is correct |
6 |
Correct |
99 ms |
9580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 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 |
2516 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Incorrect |
26 ms |
3668 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
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 |
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 |
2516 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Incorrect |
26 ms |
3668 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '16359027219341' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
24 ms |
4172 KB |
Output is correct |
2 |
Correct |
27 ms |
4940 KB |
Output is correct |
3 |
Correct |
3 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
101 ms |
9568 KB |
Output is correct |
6 |
Correct |
99 ms |
9580 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
8 |
Halted |
0 ms |
0 KB |
- |