Submission #1079483

#TimeUsernameProblemLanguageResultExecution timeMemory
1079483glupanCatfish Farm (IOI22_fish)C++17
9 / 100
58 ms13916 KiB
#include "fish.h" #include <bits/stdc++.h> #define fore(i, l, r) for(int i=int(l); i<int(r); i++) 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 ok=1,ok1=1; fore(i,0,M) { if(X[i] % 2) ok=0; if(X[i] > 1) ok1=0; } long long ans=0; if(ok) fore(i,0,M) ans+=W[i]; else if(ok1) { long long grid[2][N+5]; memset(grid,0,sizeof grid); fore(i,0,M) grid[X[i]][Y[i]] = W[i]; long long sum1=0,sum2=0,temp1=0,temp2=0; if(N > 2) { fore(i,0,N) { sum1+=grid[0][i]; sum2+=grid[1][i]; if(sum1 >= sum2 and abs(sum1-sum2) >= abs(temp1-temp2)) { temp1=sum1; temp2=sum2; } } ans = sum2-temp2+temp1; } else { fore(i,0,N) { sum1+=grid[0][i]; sum2+=grid[1][i]; } return max(sum1,sum2); } } else { long long grid[N+5]; memset(grid,0,sizeof grid); fore(i,0,M) grid[X[i]] = W[i]; long long dp[N+5][2]; memset(dp,0,sizeof dp); dp[0][1] = grid[1]; dp[0][0] = grid[0]; fore(i,1,N) { dp[i][1] = max(dp[i-1][1]+grid[i+1],dp[i-1][0]+grid[i+1]); dp[i][0] = max(dp[i-1][1]+grid[i],dp[i-1][0]+grid[i]); } ans = max(dp[N-1][1],dp[N-1][0]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...