Submission #912778

#TimeUsernameProblemLanguageResultExecution timeMemory
912778biankCatfish Farm (IOI22_fish)C++17
18 / 100
77 ms10188 KiB
#include <bits/stdc++.h> //#include "fish.h" using namespace std; #define ALL(x) x.begin(),x.end() #define SIZE(x) (int)x.size() #define forsn(i,s,n) for(int i=int(s);i<int(n);i++) #define forn(i,n) for(int i=0;i<int(n);i++) #define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--) #define dforn(i,n) for(int i=int(n)-1;i>=0;i--) #define fst first #define snd second #define pb push_back typedef pair<int,int> ii; typedef vector<ii> vii; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; const ll INF = 1e18; ll subtask1(vi &w) { ll ans=0; forn(i,SIZE(w)) ans+=w[i]; return ans; } ll subtask2(int n, vi &x, vi &y, vi &w) { if(n==1) return 0; if(n==2) { ll sum[2]={0,0}; forn(i,SIZE(w)) sum[x[i]]+=w[i]; return max(sum[0],sum[1]); } vll val[2]; forn(i,2) val[i]=vll(n+1,0); forn(i,SIZE(w)) val[x[i]][y[i]+1]+=w[i]; forn(i,n) val[0][i+1]+=val[0][i], val[1][i+1]+=val[1][i]; ll ans=0; forn(i,n+1) ans=max(ans,val[0][i]+val[1][n]-val[1][i]); return ans; } ll subtask3(int n, vi &x, vi &w) { int m=SIZE(w); vi val(n+1,0); forn(i,m) val[x[i]+1]+=w[i]; vll dp1(n+2), dp2(n+2); dp2[0]=dp2[1]=-INF; forn(i,n) { dp1[i+2]=max(dp1[i+1],dp2[i+1]+val[i+1]); dp2[i+2]=max(dp2[i+1],max(dp1[i],dp2[i])+val[i]); } return max(dp1[n+1], dp2[n+1]); } ll max_weights(int n, int m, vi x, vi y, vi w) { bool s1=true; forn(i,m) s1&=(x[i]&1)==0; if(s1) return subtask1(w); bool s2=true; forn(i,m) s2&=x[i]==0||x[i]==1; if(s2) return subtask2(n,x,y,w); bool s3=true; forn(i,m) s3&=y[i]==0; if(s3) return subtask3(n,x,w); return 0; }
#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...