Submission #385764

#TimeUsernameProblemLanguageResultExecution timeMemory
385764taulantJelly Flavours (IOI20_jelly)C++14
0 / 100
264 ms148076 KiB
#include<bits/stdc++.h> using namespace std; typedef array<int, 2> pii; int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){ int n = a.size(); vector<pii> c(n); for(int i = 0; i < n; ++i) c[i] = {a[i], b[i]}; sort(c.begin(), c.end()); vector<vector<int>> v(n+1, vector<int>(x+1)), w(n+1, vector<int>(y+1)); // v: buy i cheapest jelly, given money spent in a, find min extra cost in b for(int i = 1; i <= n; ++i){ for(int j = 0; j <= x; ++j){ v[i][j] = v[i-1][j] + c[i-1][1]; if(j >= c[i-1][0]) v[i][j] = min(v[i][j], v[i-1][j-c[i-1][0]]); } } // w: buy in b jelly that would be expensive in a, find max jelly for(int i = n-1; i >= 0; --i){ for(int j = 0; j <= y; ++j){ w[i][j] = w[i+1][j]; if(j >= c[i][1]) v[i][j] = max(v[i][j], v[i+1][j-c[i+1][1]]+1); } } int ans = 0; for(int i = 0; i <= n; ++i){ int yy = y - v[i][x]; if(yy >= 0) ans = max(ans, i + w[i][yy]); } return ans; }
#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...