제출 #938184

#제출 시각아이디문제언어결과실행 시간메모리
938184irmuun메기 농장 (IOI22_fish)C++17
9 / 100
75 ms7268 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() ll max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){ int even=0,X=0,Y=0; for(int i=0;i<m;i++){ X=max(X,x[i]); Y=max(Y,y[i]); if(x[i]%2==0) even++; } if(even==m){ ll ans=0; for(int i=0;i<m;i++){ ans+=w[i]; } return ans; } if(X<=1){ ll ans=0,cur=0; for(int i=0;i<m;i++){ if(x[i]==0){ ans+=w[i]; } else{ cur+=w[i]; } } if(n==2) return max(ans,cur); ll sum[n][2]; memset(sum,0,sizeof sum); for(int i=0;i<m;i++){ sum[y[i]][x[i]]+=w[i]; } for(int i=1;i<n;i++){ sum[i][0]+=sum[i-1][0]; sum[i][1]+=sum[i-1][1]; } ans=max(ans,cur); for(int i=0;i<n;i++){ ans=max(ans,sum[i][0]+sum[n-1][1]-sum[i][1]); } return ans; } if(Y==0){ ll sum[n]; fill(sum,sum+n,0); for(int i=0;i<m;i++){ sum[x[i]]+=w[i]; } ll dp[n][2][2];//i, i,i-1 dp[1][0][0]=0; dp[1][0][1]=sum[0]; dp[1][1][0]=sum[1]; dp[1][1][1]=0; for(ll i=2;i<n;i++){ dp[i][1][1]=max(dp[i-1][1][0],dp[i-1][1][1]); dp[i][1][0]=max(dp[i-1][0][1],dp[i-1][0][0]+sum[i-1]); dp[i][0][1]=max(dp[i-1][1][0],dp[i-1][1][1])+sum[i]; dp[i][0][0]=max(dp[i-1][0][1],dp[i-1][0][0]); } return max({dp[n-1][0][0],dp[n-1][0][1],dp[n-1][1][0],dp[n-1][1][1]}); } return 0ll; }
#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...