#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();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
293 ms |
16044 KB |
Output is correct |
2 |
Correct |
268 ms |
15960 KB |
Output is correct |
3 |
Correct |
260 ms |
15964 KB |
Output is correct |
4 |
Correct |
269 ms |
15960 KB |
Output is correct |
5 |
Correct |
266 ms |
15960 KB |
Output is correct |
6 |
Correct |
256 ms |
15960 KB |
Output is correct |
7 |
Correct |
234 ms |
15960 KB |
Output is correct |
8 |
Correct |
268 ms |
15964 KB |
Output is correct |
9 |
Correct |
264 ms |
16064 KB |
Output is correct |
10 |
Correct |
276 ms |
15964 KB |
Output is correct |
11 |
Correct |
226 ms |
15964 KB |
Output is correct |
12 |
Correct |
237 ms |
15964 KB |
Output is correct |
13 |
Correct |
295 ms |
15964 KB |
Output is correct |
14 |
Correct |
232 ms |
16212 KB |
Output is correct |
15 |
Correct |
237 ms |
16076 KB |
Output is correct |
16 |
Correct |
244 ms |
15964 KB |
Output is correct |
17 |
Correct |
250 ms |
16212 KB |
Output is correct |
18 |
Correct |
245 ms |
15964 KB |
Output is correct |
19 |
Correct |
238 ms |
15964 KB |
Output is correct |
20 |
Correct |
244 ms |
16048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |