제출 #300394

#제출 시각아이디문제언어결과실행 시간메모리
300394MarcoMeijerJelly Flavours (IOI20_jelly)C++14
100 / 100
79 ms760 KiB
#include <bits/stdc++.h> #include "jelly.h" using namespace std; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define RE(a,b) REP(a,0,b) #define FOR(a,b) for(auto& a:b) #define pb push_back #define fi first #define se second #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<int,int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int INF=1e9; const int MX=10001; int find_maximum_unique(int x, int y, vi a, vi b) { int n = a.size(); int ans = 0; // sort a and b, with increasing a vi sa; sa.resize(n); RE(i,n) sa[i] = i; sort(all(sa), [&](int i, int j) { if(a[i] == a[j]) return b[i] > b[j]; return a[i] < a[j]; }); vi na = a, nb = b; RE(i,n) na[i] = a[sa[i]]; RE(i,n) nb[i] = b[sa[i]]; a = na; b = nb; multiset<int> T; RE(i,n) T.insert(b[i]); vi dp; dp.assign(MX,0); vi dpb; dpb.assign(MX,0); RE(i,n) { // update T T.erase(T.find(b[i])); // get new dp vi ndp; ndp.resize(MX); RE(j,MX+1) { ndp[j] = dp[j] + b[i]; if(j-a[i] >= 0) ndp[j] = min(ndp[j], dp[j-a[i]]); } dp = ndp; if(dp[x] > y) break; // it is not possible to buy all candy from [0,i] int remaining = y-dp[x]; int curAns = i+1; FOR(t,T) { if(remaining >= t) { remaining -= t; curAns++; } else { break; } } ans = max(ans, curAns); } 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...