# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757921 | gelov | Gym Badges (NOI22_gymbadges) | C++17 | 2079 ms | 65060 KiB |
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;
int ans = 1;
void solve(vector<int> a, vector<int> b, int level, int badges) {
if (a.size() == 0) {
ans = max(ans, badges);
}
else {
bool found = false;
for (int i = 0; i < a.size(); i++) {
if (b[i] >= level) {
found = true;
vector<int> c;
vector<int> d;
for (int j = 0; j < a.size(); j++) {
if (j != i) {
c.push_back(a[j]);
d.push_back(b[j]);
}
}
solve(c, d, level + a[i], badges + 1);
}
}
if (!found) {
ans = max(ans, badges);
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
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];
solve(a, b, 0, 0);
cout << ans << "\n";
}
Compilation message (stderr)
# | 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... |