Submission #1314824

#TimeUsernameProblemLanguageResultExecution timeMemory
1314824samarthkulkarniGym Badges (NOI22_gymbadges)C++20
9 / 100
106 ms8248 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define vi vector<long long>
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pr pair<ll, ll>
#define ff first
#define ss second

void solution();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


const int N = 5e5+10;
pr a[N];

void solution() {

    ll n; cin >> n; 
    for (int i = 0; i < n; i++) cin >> a[i].ff;
    for (int i = 0; i < n; i++) cin >> a[i].ss;


    sort(a, a+n);

    ll cnt = 0;
    ll x = 0;

    for (int i = 0; i < n; i++) {
        if (x <= a[i].ss) {
            cnt++;
            x += a[i].ff;
        }
    }

    cout << cnt << endl;



}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...