Source Code
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    ll s;
    cin>>n>>s;

    vector<pair<int,int>>a(n);

    for(auto &[x,y]:a) cin>>x;
    for(auto &[x,y]:a) cin>>y;

    sort(a.begin(),a.end());
    int ans=0;

    for(int i=0;i<n;i++){
        ans++;
        if(a[i].first>=s){
            break;
        } else {
            s-=a[i].first;
            s+=a[i].second;
        }
    }

    cout<<ans;
}
Copy
Wheatly's portals - Easy version YazanIstatiyeh
GNU G++17
2 ms
256 KB
Wrong Answer