#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
typedef long long ll;
#define st first
#define nd second
#define pb push_back
const int maxn = 2003;
int dp[2003][10003];
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
vector<pair<int,int>> sortowane;
int n=a.size();
for(int i=0;i<n;i++){
sortowane.pb({a[i],b[i]});
}
sort(sortowane.begin(),sortowane.end());
dp[0][0] = y;
int wyn=0,akt,ile;
vector<int> reszta;
for(int i=1;i<=n;i++){
for(int j=0;j<=x;j++){
dp[i][j] = -1e9;
if(j >= sortowane[i-1].st)
dp[i][j] = max(dp[i][j],dp[i-1][j-sortowane[i-1].st]);
if(dp[i-1][j] >= sortowane[i-1].nd)
dp[i][j] = max(dp[i][j],dp[i-1][j] - sortowane[i-1].nd);
}
akt = i;
if(dp[i][x] < 0)
break;
ile = dp[i][x];
reszta.clear();
for(int j=i+1;j<=n;j++){
reszta.pb(sortowane[i-1].nd);
}
sort(reszta.begin(),reszta.end());
for(auto j : reszta){
if(j > ile)
break;
ile -= j;
akt++;
}
if(akt == 5)
cout<<i<<"\n";
wyn = max(wyn,akt);
}
return wyn;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |