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>
using namespace std;
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, b, a) for(int i = (b), _a = (a); i >= _a; --i)
#define REP(i, a, b) for(int i = (a), _b = (b); i < _b; ++i)
#define REPD(i, b, a) for(int i = (b), _a = (a); i > _a; --i)
#define MASK(i) (1LL << (i))
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define __builtin_popcount __builtin_popcountll
#define all(val) val.begin(), val.end()
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(v) (int)v.size()
#define fi first
#define se second
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll Rand(ll l, ll r) {return l + rng() % (r - l + 1);}
template<class X, class Y>
bool minimize(X &x, const Y &y) {
if (x > y) {
x = y;
return true;
} else return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
if (x < y) {
x = y;
return true;
} else return false;
}
template<class T>
T Abs(const T &x) {
return (x < 0 ? -x : x);
}
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e3 + 5;
const int maxn = 1e4 + 5;
int pre[N][maxn], suf[N][maxn];
#include "jelly.h"
int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) {
int n = a.size();
vector<pii> v;
REP(i, 0, n) v.emplace_back(a[i], b[i]);
sort(all(v));
REP(i, 0, n) FOR(j, 0, x) {
pre[i + 1][j] = pre[i][j] + v[i].se;
if(j >= v[i].fi)
minimize(pre[i + 1][j], pre[i][j - v[i].fi]);
}
FORD(i, n - 1, 0) FOR(j, 0, y) {
suf[i + 1][j] = suf[i + 2][j];
if(j >= v[i].se)
maximize(suf[i + 1][j], suf[i + 2][j - v[i].se] + 1);
}
int res = 0;
FOR(i, 0, n) if(pre[i][x] <= y) {
maximize(res, i + suf[i + 1][y - pre[i][x]]);
}
return res;
}
// void process() {
// int n, x, y; cin >> n >> x >> y;
// vector<int> a(n), b(n);
// for(int &val : a) cin >> val;
// for(int &val : b) cin >> val;
// cout << find_maximum_unique(x, y, a, b);
// }
// signed main() {
// if(fopen("test.inp","r")) {
// freopen("test.inp","r",stdin);
// freopen("test.out","w",stdout);
// }
// ios::sync_with_stdio(0);
// cin.tie(0); cout.tie(0);
// // clock_t start = clock();
// int ntests = 1;
// // cin >> ntests;
// while(ntests--) process();
// // cerr << "Time elapsed: " << clock() - start << " ms!\n";
// return 0;
// }
// https://oj.uz/problem/view/IOI20_jelly
# | 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... |