This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pii pair<int,int>
bool cmp(pii a ,pii b)
{
return a.ff < b.ff;
}
void solve()
{
int n;
cin>>n;
vector <int> x(n),l(n);
vector <pii> a(n);
for(int i=0;i<n;i++)
{
cin>>x[i];
a[i].ff = x[i];
}
for(int i=0;i<n;i++)
{
cin>>l[i];
a[i].ss = l[i];
}
sort(a.begin(),a.end());
int cur = 0;
int ans = n;
for(int i=0;i<n;i++)
{
if(cur>l[0])
{
ans = i;
break;
}
cur += a[i].ff;
//cout << cur << " " << ans << "\n";
}
cout << ans << "\n";
}
signed main()
{
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |