#include<bits/stdc++.h>
#include "fish.h"
#include <vector>
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) {
vector<ll>sum(N, 0), dp(N, 0);
for (int i = 0; i < M; i++)
sum[X[i]] += W[i];
dp[N - 1] = sum[N - 1];
for (int i = N - 2; i >= 0; i--) {
if (!sum[i])
dp[i] = dp[i + 1];
else {
if (!sum[i + 1])
dp[i] = sum[i] + dp[i + 1];
else {
int val = 0;
if (i != N - 2)
val = dp[i + 2];
dp[i] = max(dp[i + 1], (sum[i] + val));
}
}
}
return dp[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3540 KB |
Output is correct |
2 |
Correct |
28 ms |
4176 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Correct |
90 ms |
8812 KB |
Output is correct |
6 |
Correct |
83 ms |
8816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Incorrect |
14 ms |
2864 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '2452061013987' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Incorrect |
14 ms |
2864 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '2452061013987' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3540 KB |
Output is correct |
2 |
Correct |
28 ms |
4176 KB |
Output is correct |
3 |
Correct |
1 ms |
1748 KB |
Output is correct |
4 |
Correct |
1 ms |
1748 KB |
Output is correct |
5 |
Correct |
90 ms |
8812 KB |
Output is correct |
6 |
Correct |
83 ms |
8816 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 |
- |