Submission #757935

# Submission time Handle Problem Language Result Execution time Memory
757935 2023-06-14T02:14:14 Z gelov Gym Badges (NOI22_gymbadges) C++17
24 / 100
2000 ms 4236 KB
#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);
    set<int> c;

    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        c.insert(b[i]);
    }

    if (c.size() == 1) {
        sort(a.begin(), a.end());
        int level = 0, badges = 0;
        for (int i = 0; i < a.size(); i++) {
            if (level <= b[i]) {
                level += a[i];
                badges++;
            }
        }
        ans = max(ans, badges);
    }
    else solve(a, b, 0, 0);

    cout << ans << "\n";
}

Compilation message

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++) {
      |                                 ~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:52:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for (int i = 0; i < a.size(); i++) {
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 29 ms 212 KB Output is correct
20 Correct 31 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 155 ms 4224 KB Output is correct
2 Correct 157 ms 4180 KB Output is correct
3 Correct 131 ms 4180 KB Output is correct
4 Correct 169 ms 4180 KB Output is correct
5 Correct 150 ms 4180 KB Output is correct
6 Correct 142 ms 4228 KB Output is correct
7 Correct 144 ms 4232 KB Output is correct
8 Correct 147 ms 4220 KB Output is correct
9 Correct 143 ms 4224 KB Output is correct
10 Correct 172 ms 4180 KB Output is correct
11 Correct 114 ms 4180 KB Output is correct
12 Correct 115 ms 4224 KB Output is correct
13 Correct 110 ms 4180 KB Output is correct
14 Correct 118 ms 4228 KB Output is correct
15 Correct 118 ms 4180 KB Output is correct
16 Correct 120 ms 4180 KB Output is correct
17 Correct 123 ms 4220 KB Output is correct
18 Correct 125 ms 4236 KB Output is correct
19 Correct 127 ms 4180 KB Output is correct
20 Correct 159 ms 4236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 29 ms 212 KB Output is correct
20 Correct 31 ms 212 KB Output is correct
21 Execution timed out 2084 ms 1984 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 29 ms 212 KB Output is correct
20 Correct 31 ms 212 KB Output is correct
21 Correct 155 ms 4224 KB Output is correct
22 Correct 157 ms 4180 KB Output is correct
23 Correct 131 ms 4180 KB Output is correct
24 Correct 169 ms 4180 KB Output is correct
25 Correct 150 ms 4180 KB Output is correct
26 Correct 142 ms 4228 KB Output is correct
27 Correct 144 ms 4232 KB Output is correct
28 Correct 147 ms 4220 KB Output is correct
29 Correct 143 ms 4224 KB Output is correct
30 Correct 172 ms 4180 KB Output is correct
31 Correct 114 ms 4180 KB Output is correct
32 Correct 115 ms 4224 KB Output is correct
33 Correct 110 ms 4180 KB Output is correct
34 Correct 118 ms 4228 KB Output is correct
35 Correct 118 ms 4180 KB Output is correct
36 Correct 120 ms 4180 KB Output is correct
37 Correct 123 ms 4220 KB Output is correct
38 Correct 125 ms 4236 KB Output is correct
39 Correct 127 ms 4180 KB Output is correct
40 Correct 159 ms 4236 KB Output is correct
41 Execution timed out 2084 ms 1984 KB Time limit exceeded
42 Halted 0 ms 0 KB -