Submission #886486

# Submission time Handle Problem Language Result Execution time Memory
886486 2023-12-12T08:25:24 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
0 / 100
365 ms 15496 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()

int main(){
    int n;
    cin>>n;

    vector<int> a(n), b(n), x(n);
    for(auto &e:a) cin>>e;
    for(auto &e:b) cin>>e;

    iota(all(x), 0);
    sort(all(x), [&](int l, int r){
        return (b[l]-a[r]<min({b[l], b[r], b[r]-a[l]}));
    });

    int ans=0;
    for(int mask=0; mask<(1<<n); mask++){
        bool f=1;
        int cur=0;
        for(int i=0; i<n; i++){
            if(mask&(1<<i)){
                if(cur<=b[i]){
                    cur+=a[i];
                }
                else{
                    f=0;
                    break;
                }
            }
        }
        if(f) ans=max(ans, __builtin_popcount(mask));
    }

    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 365 ms 15496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -