#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(),cmp);
int cur = 0;
int ans = 0;
for(int i=0;i<n;i++)
{
cur += a[i].ff;
if(cur>l[0])
{
break;
}
//cout << cur << " " << ans << "\n";
ans++;
}
cout << ans << "\n";
}
signed main()
{
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
286 ms |
16052 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |