# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1079182 | vjudge1 | 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 <bits/stdc++.h>
#define div /
#define ll long long
#define fore(i, l, r) for(int i=int(l); i<int(r); i++)
#define sz(a) int((a).size())
using namespace std;
const int INF = 1e9;
const int MX = 5e5 + 23;
const int MOD = 1000000007;
const int MAX_N = 5e5+23;
const int N = 1e6;
int64 max_weights(int N, int M, int[] X, int[] Y, int[] W) {
int ok=1,ok1=1;
fore(i,0,m) {
if(x[i] % 2)
ok=0;
if(x[i] > 1)
ok1=0;
}
int ans=0;
if(ok)
fore(i,0,m)
ans+=w[i];
else if(ok1) {
int sum1=0,sum2=0;
fore(i,0,m) {
if(x[i] == 0)
sum1+=w[i];
else
sum2+=w[i];
}
ans = max(sum1,sum2);
} else {
int dp[n+5];
memset(dp,0,sizeof dp);
int grid[n+5];
memset(grid,0,sizeof grid);
fore(i,0,m)
grid[x[i]] = w[i];
fore(i,0,n) {
dp[i] = grid[i];
if(i > 1)
dp[i] += dp[i-2];
if(i)
dp[i] = max(dp[i],dp[i-1]);
}
ans = dp[n-1];
}
return ans;
}