Submission #426320

#TimeUsernameProblemLanguageResultExecution timeMemory
426320ApiramJelly Flavours (IOI20_jelly)C++14
54 / 100
254 ms186564 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){ int dp [n+1][x+1][y+1]; memset(dp,0,sizeof dp); for (int i =1;i<=n;++i){ for (int j =0;j<=x;++j){ for (int k =0;k<=y;++k){ dp[i][j][k] = max({(j-arr[i-1]>=0)?dp[i-1][j-arr[i-1]][k]+1:0,(k-brr[i-1]>=0)?dp[i-1][j][k-brr[i-1]]+1:0,dp[i-1][j][k],dp[i][j][k]}); } } } return dp[n][x][y];} else { int dp1[n+1][x+1],dp2[n+1][y+1]; memset(dp1,0,sizeof dp1); memset(dp2,0,sizeof dp2); for (int i =1;i<=n;++i){ for (int j =0;j<=x;++j){ dp1[i][j] = max({dp1[i-1][j-arr[i-1]]+1,dp1[i][j],dp1[i-1][j]}); } for (int j =0;j<=y;++j){ dp2[i][j] = max({dp2[i-1][j-brr[i-1]]+1,dp2[i][j],dp2[i-1][j],(j<=x)?dp1[i][j]:0}); } } return dp2[n][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...