#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, dem = 0, dem1 = 0;
pair<int, int> p[1000005];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> p[i].first;
}
for(int i = 1; i <= n; i++){
cin >> p[i].second;
}
sort(p + 1, p + n + 1);
for(int i = 1; i <= n; i++){
if(dem <= p[i].second){
dem += p[i].first;
dem1++;
}
}
cout << dem1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
8784 KB |
Output is correct |
2 |
Correct |
106 ms |
18144 KB |
Output is correct |
3 |
Correct |
104 ms |
17992 KB |
Output is correct |
4 |
Correct |
107 ms |
17992 KB |
Output is correct |
5 |
Correct |
113 ms |
17992 KB |
Output is correct |
6 |
Correct |
101 ms |
17016 KB |
Output is correct |
7 |
Correct |
99 ms |
16468 KB |
Output is correct |
8 |
Correct |
102 ms |
16968 KB |
Output is correct |
9 |
Correct |
111 ms |
17224 KB |
Output is correct |
10 |
Correct |
101 ms |
16972 KB |
Output is correct |
11 |
Correct |
94 ms |
15956 KB |
Output is correct |
12 |
Correct |
94 ms |
15868 KB |
Output is correct |
13 |
Correct |
93 ms |
15956 KB |
Output is correct |
14 |
Correct |
102 ms |
16108 KB |
Output is correct |
15 |
Correct |
95 ms |
15944 KB |
Output is correct |
16 |
Correct |
103 ms |
16380 KB |
Output is correct |
17 |
Correct |
100 ms |
16456 KB |
Output is correct |
18 |
Correct |
103 ms |
16508 KB |
Output is correct |
19 |
Correct |
101 ms |
16500 KB |
Output is correct |
20 |
Correct |
98 ms |
16456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |