# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
778520 | Mouad_ouj | Catfish Farm (IOI22_fish) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "fish.h"//sub3
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int n, int m,vector<int> b,vector<int> y,vector<int> w)
{
long long tab[n]={0},dp[n][4]={0};
for(int a=0;a<m;a++)
tab[b[a]]=w[a];
dp[0][0]=tab[0];dp[0][1]=tab[0];
dp[0][2]=tab[0];dp[0][3]=tab[0];
for(int a=2;a<n;a++)
{
dp[x][0]=max(dp[x-1][0],dp[x-1][1]+tab[x-1]);
dp[x][1]=max(dp[x-1][3]+tab[x],dp[x-1][2]+tab[x]);
dp[x][2]=max(dp[x-1][1],dp[x-1][0]+tab[x-1]);
dp[x][3]=max(dp[x-1][3],dp[x-1][2]);
}
long long ans=max(max(dp[n-1][0],dp[n-1][1]),max(dp[n-1][2],dp[n-1][3]));
return ans;
}