#include "fish.h"
#include<bits/stdc++.h>
#define ll long long
#include <vector>
ll mx(ll a,ll b){
if(a>b) return a;
return b;
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
ll dp[N][2],a[N];
for(int i=0;i<N;i++){
dp[i][0]=dp[i][1]=a[i]=0;
}
for(int i=0;i<M;i++){
a[X[i]]=1ll*W[i];
}
dp[0][1]=a[0];
dp[1][0]=a[0];
dp[1][1]=a[1];
ll ans=mx(a[0],a[1]);
if(N>2){
dp[2][1]=mx(a[1],a[0]+a[2]);
dp[2][0]=mx(a[0],a[1]);
ans=mx(ans,a[2]);
if(N>3){
ans=mx(ans,a[1]+a[2]);
}
}
for(int i=3;i<N;i++){
dp[i][0]=dp[i-3][0]+a[i-2]+a[i-1];
dp[i][1]=mx(dp[i-2][1],dp[i-2][0]+a[i-1])+a[i];
}
ans=mx(dp[N-1][0],dp[N-1][1]);
return ans;
}
/*
9 9
0 0 1
1 0 4
2 0 5
3 0 2
4 0 1
5 0 5
6 0 3
7 0 2
8 0 1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
4172 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Incorrect |
17 ms |
3668 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '17841302602949' |
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 |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2516 KB |
Output is correct |
3 |
Incorrect |
17 ms |
3668 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '17841302602949' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
4172 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |