제출 #912774

#제출 시각아이디문제언어결과실행 시간메모리
912774biank메기 농장 (IOI22_fish)C++17
12 / 100
76 ms13924 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; 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]); } int m=SIZE(x); ll sum=0; forn(i,m) if(x[i]==1) sum+=w[i]; ll val[2]={0,0},ans=sum; vii p(m); forn(i,n) p[i]={y[i],x[i]}; sort(ALL(p)); forn(i,m) { val[p[i].snd]+=w[i]; ans=max(ans,val[0]+sum-val[1]); } 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]; vector<ll> 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...