Submission #793022

#TimeUsernameProblemLanguageResultExecution timeMemory
793022ln_eJelly Flavours (IOI20_jelly)C++17
100 / 100
104 ms156968 KiB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho #include "jelly.h" using ll=long long; using ld=long double; int const INF=1000000005; ll const LINF=1000000000000000005; ll const mod=6700417; ld const PI=3.14159265359; ll const MAX_N=3e5+5; ld const EPS=0.00000001; #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define f first #define s second #define pb push_back #define mp make_pair #define endl '\n' #define sz(a) (int)a.size() #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; pair<int,int>p[2005]; pair<int,int> dp[2005][10005]; int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) { int n = a.size(); int ans=0; for(int i=0;i<n;i++) { p[i+1].f=a[i]; p[i+1].s=b[i]; } sort(p+1,p+n+1); for(ll j=y;j>=0;j--) { dp[0][j]=mp(0,x); } for(ll i=1;i<=n;i++) { for(ll j=y;j>=0;j--) { dp[i][j]=dp[i-1][j]; if(dp[i-1][j].s>=p[i].f){ dp[i][j].f++; dp[i][j].s-=p[i].f; } if(j+p[i].s<=y){ if(dp[i-1][j+p[i].s].f+1>dp[i][j].f){ dp[i][j]=dp[i-1][j+p[i].s]; dp[i][j].f++; }else if(dp[i-1][j+p[i].s].f+1==dp[i][j].f&&dp[i-1][j+p[i].s].s>dp[i][j].s){ dp[i][j]=dp[i-1][j+p[i].s]; dp[i][j].f++; } } ans=max(ans,dp[i][j].f); } } 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...