답안 #886521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886521 2023-12-12T09:23:53 Z okaragul Gym Badges (NOI22_gymbadges) C++17
0 / 100
328 ms 17492 KB
#include <bits/stdc++.h>
using namespace std;

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

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

    vector<ll> 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), [&](ll l, ll 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;
        ll cur=0;
        for(ll 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 328 ms 17492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -