제출 #443104

#제출 시각아이디문제언어결과실행 시간메모리
443104definitelynotmeeJelly Flavours (IOI20_jelly)C++17
0 / 100
158 ms90576 KiB
#include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define ff first #define ss second using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 1e9 + 7; const int MAXN = 1e6+1; int find_maximum_unique(int x, int y, vector<int> a, vector<int> b){ int n = a.size(); vector<int> order(n); iota(order.begin(),order.end(),0); sort(order.begin(),order.end(),[&](int c, int d){return a[c] < a[d];}); vector<multiset<int>> v(n+1); for(int i = n-1; i >= 0; i--){ v[i] = v[i+1]; v[i].insert(b[order[i]]); } int resp = 0; int cury = y; for(int i : v[0]){ if(i <= cury) cury-=i, resp++; else break; } vector<int> dp(x+1,0); for(int i = 0; i < n; i++){ //cerr << i << endl; for(int j = x; j >= 0; j--){ dp[j] = min(dp[j] + b[i], i >= a[i] ? dp[j-a[i]] : INF); } if(dp[x] > y) break; int curresp = i+1; cury = y-dp[x]; for(int j : v[i+1]){ if(j > cury) break; curresp++; cury-=j; } resp = max(resp,curresp); } return resp; } /*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 << "resp = " << find_maximum_unique(x,y,a,b) << '\n'; }*/
#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...