#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
long long dp[N][2];
sort(X.begin(),X.end());
long long c;
if(X[0]==0)
c=W[0];
else
c=0;
dp[0][0]=0;
dp[0][1]=c;
if(X[0]==1)
c=W[0];
else {
if (X[1] == 1)
c = W[1];
else
c = 0;
}
dp[1][1]=max(dp[0][1],c);
dp[1][0]=max(dp[0][1],c);
int index;
if(X[0]==0 && X[1]==1)
index=2;
if(X[0]==0 && X[1]!=1)
index=1;
if(X[0]==1 )
index=1;
if(X[0]!=1 && X[0]!=0)
index=0;
for(int i=2;i<N;i++){
if(i==X[index]) {
c = W[index];
index++;
}
else
c=0;
dp[i][1]=max(dp[i-1][1],dp[i-1][0]+c);
dp[i][0]=max(dp[i-1][1],max(dp[i-2][0],dp[i-2][1]+c));
}
return dp[N-1][0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
4944 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '55091480' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 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 |
1880 KB |
Output is correct |
2 |
Correct |
1 ms |
1968 KB |
Output is correct |
3 |
Incorrect |
13 ms |
4052 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '21239949977343' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1880 KB |
Output is correct |
2 |
Correct |
1 ms |
1968 KB |
Output is correct |
3 |
Incorrect |
13 ms |
4052 KB |
1st lines differ - on the 1st token, expected: '21261825233649', found: '21239949977343' |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
4944 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '55091480' |
2 |
Halted |
0 ms |
0 KB |
- |