Submission #1312020

#TimeUsernameProblemLanguageResultExecution timeMemory
1312020norrawichzzzJelly Flavours (IOI20_jelly)C++20
0 / 100
2155 ms1907908 KiB
#include <bits/stdc++.h> using namespace std; int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) { int n=a.size(); vector<vector<pair<int,int>>> candidate(n+2); candidate[0].push_back({0,0}); vector<int> dp(n+1); dp[0] = 0; for (int i=1; i<=n; i++) { dp[i]=dp[i-1]; for (int j=0; j<dp[i]; j++) { for (auto &e : candidate[j]) { if (e.first + a[i-1] <= x) candidate[j+1].push_back({e.first + a[i-1], e.second}); if (e.second + b[i-1] <= y) candidate[j+1].push_back({e.first, e.second + b[i-1]}); } } bool ok=false; for (auto &e : candidate[dp[i]]) { if (e.first + a[i-1] <= x) { candidate[dp[i]+1].push_back({e.first + a[i-1], e.second}); ok=true; } if (e.second + b[i-1] <= y) { candidate[dp[i]+1].push_back({e.first, e.second + b[i-1]}); ok=true; } } if (ok && i<n) dp[i]++; } return dp[n]; } /* int main() { int n,x,y; cin>> n>> x>> y; vector<int> a(n), b(n); for (int i=0; i<n; i++) cin>> a[i]; for (int i=0; i<n; i++) cin>> b[i]; cout<< find_maximum_unique(x, y, a, b); }*/
#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...