Submission #426587

#TimeUsernameProblemLanguageResultExecution timeMemory
426587ApiramJelly Flavours (IOI20_jelly)C++14
24 / 100
225 ms152204 KiB
#include "jelly.h" #include <cstdio> #include <cassert> #include <vector> #include<bits/stdc++.h> using namespace std; int find_maximum_unique(int x, int y, std::vector<int> arr, std::vector<int> brr) { int n = arr.size(); bool ok=true; bool okay=true; for (int i =0;i<n;++i){ if (arr[i]!=brr[i]){ ok=false; } if (i>0){ if (brr[i]!=brr[i-1])okay=false; } } if (okay){ vector<pair<int,int>>crr(n); for (int i=0;i<n;++i){ crr[i]={arr[i],brr[i]}; } sort(crr.begin(),crr.end()); int ans=0; n--; while(n>=0){ if (y-crr[n].second>=0){ y-=crr[n].second; --n; ans++; } else break; } for (int i =0;i<=n;++i){ if (x-crr[i].first<0)break; x-=crr[i].first; ans++; } return ans; } if (!ok){ vector<pair<int,int>>crr; for(int i =0;i<n;++i){ crr.push_back({arr[i],brr[i]}); } sort(crr.begin(),crr.end()); vector<pair<int,int>>dp(x+1,{-1,-1}); dp[0]={0,0}; for (int i =0;i<n;++i){ for (int j =x;j>=0;--j){ if (dp[j].first==-1)continue; if (j+crr[i].first<=x){ dp[j+crr[i].first].first = dp[j].first+1; dp[j+crr[i].first].second=dp[j].second; } if (dp[j].second+crr[i].second<=y){ dp[j].second=dp[j].second+crr[i].second; dp[j].first=dp[j].first+1; } } } int ans=0; for (int i =0;i<=x;++i){ if (dp[i].second<=y) ans=max(ans,dp[i].first); } return ans; } else { int dp1[n+1][x+y+1]; memset(dp1,0,sizeof dp1); for (int i =1;i<=n;++i){ for (int j =0;j<=x+y;++j){ dp1[i][j] = max({(j-arr[i-1]>=0)?dp1[i-1][j-arr[i-1]]+1:0,dp1[i][j],dp1[i-1][j]}); } } return dp1[n][x+y]; } }
#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...