Submission #426313

#TimeUsernameProblemLanguageResultExecution timeMemory
426313ApiramJelly Flavours (IOI20_jelly)C++14
54 / 100
1006 ms2097156 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; } 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]; }

Compilation message (stderr)

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:9:7: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
    9 |  bool ok=true;
      |       ^~
#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...