Submission #757921

#TimeUsernameProblemLanguageResultExecution timeMemory
757921gelovGym Badges (NOI22_gymbadges)C++17
15 / 100
2079 ms65060 KiB
#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)

Main.cpp: In function 'void solve(std::vector<int>, std::vector<int>, int, int)':
Main.cpp:12:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for (int i = 0; i < a.size(); i++) {
      |                         ~~^~~~~~~~~~
Main.cpp:18:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |                 for (int j = 0; j < a.size(); j++) {
      |                                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...