This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "jelly.h"
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define fr first
#define sc second
const int MAX = 2005;
const int INF = 0x3f3f3f3f;
int a[MAX], b[MAX];
pair<int, int> dp[MAX][10 * MAX];
int find_maximum_unique(int x, int y, vector<int> _a, vector<int> _b){
int n = _a.size();
vector<pair<int, int>> aux;
for(int i = 0; i < n; i++)
aux.emplace_back(_a[i], _b[i]);
sort(aux.begin(), aux.end());
for(int i = 1; i <= n; i++){
a[i] = aux[i - 1].fr;
b[i] = aux[i - 1].sc;
}
dp[0][0] = {0, x};
for(int i = 1; i <= y; i++)
dp[0][i] = {-INF, -INF};
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= y; j++){
dp[i][j] = dp[i - 1][j];
if(dp[i][j].sc >= a[i])
dp[i][j].fr++, dp[i][j].sc -= a[i];
if(j >= b[i]){
pair<int, int> t = dp[i - 1][j - b[i]];
t.fr++;
if(t.fr > dp[i][j].fr || (t.fr == dp[i][j].fr && t.sc > dp[i][j].sc))
dp[i][j] = t;
}
ans = max(ans, dp[i][j].fr);
}
}
return ans;
}
# | 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... |