#include "fish.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w){
vector<ll> fish(n+1,0);
for(int i=0;i<m;i++) fish[x[i]]=w[i];
ll dp[n][2][2][2]; // 0: not pound | 1: pound
memset(dp,0,sizeof dp);
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
dp[0][i][j][0]=dp[0][i][j][1]=0;
for(int i=0;i<2;i++){
dp[1][i][0][0]=0;
dp[1][i][0][1]=fish[0];
dp[1][i][1][0]=fish[1];
dp[1][i][1][1]=0;
}
for(int i=2;i<n;i++){
for(int j=0;j<2;j++){
for(int k=0;k<2;k++){
dp[i][0][0][0]=max(dp[i][0][0][0],dp[i-2][j][k][0]);
dp[i][0][0][1]=max(dp[i][0][0][1],dp[i-2][j][k][0]+fish[i-1]);
dp[i][0][1][0]=max(dp[i][0][1][0],dp[i-2][j][k][0]+fish[i-2]+fish[i]-k*fish[i-2]);
dp[i][0][1][1]=max(dp[i][0][1][1],dp[i-2][j][k][0]+fish[i-2]-k*fish[i-2]);
dp[i][1][0][0]=max(dp[i][1][0][0],dp[i-2][j][k][1]+fish[i-1]);
dp[i][1][0][1]=max(dp[i][1][0][1],dp[i-2][j][k][1]+fish[i-1]);
dp[i][1][1][0]=max(dp[i][1][1][0],dp[i-2][j][k][1]+fish[i]);
dp[i][1][1][1]=max(dp[i][1][1][1],dp[i-2][j][k][1]);
}
}
}
ll res=0;
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
for(int k=0;k<2;k++)
res=max(res,dp[n-1][i][j][k]);
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
9812 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
7252 KB |
Output is correct |
2 |
Correct |
6 ms |
7252 KB |
Output is correct |
3 |
Correct |
19 ms |
8724 KB |
Output is correct |
4 |
Correct |
18 ms |
8788 KB |
Output is correct |
5 |
Correct |
32 ms |
11308 KB |
Output is correct |
6 |
Correct |
26 ms |
10620 KB |
Output is correct |
7 |
Correct |
29 ms |
11188 KB |
Output is correct |
8 |
Correct |
31 ms |
11176 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 |
6 ms |
7252 KB |
Output is correct |
2 |
Correct |
6 ms |
7252 KB |
Output is correct |
3 |
Correct |
19 ms |
8724 KB |
Output is correct |
4 |
Correct |
18 ms |
8788 KB |
Output is correct |
5 |
Correct |
32 ms |
11308 KB |
Output is correct |
6 |
Correct |
26 ms |
10620 KB |
Output is correct |
7 |
Correct |
29 ms |
11188 KB |
Output is correct |
8 |
Correct |
31 ms |
11176 KB |
Output is correct |
9 |
Incorrect |
32 ms |
11044 KB |
1st lines differ - on the 1st token, expected: '99999', found: '66666' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
9812 KB |
1st lines differ - on the 1st token, expected: '40313272768926', found: '803213453' |
2 |
Halted |
0 ms |
0 KB |
- |