#include <bits/stdc++.h>
using namespace std;
#define tol(bi) (1ll<<((int)(bi)))
int main(){
int n;
cin>>n;
vector<pair<int,int>> arr(n);
for (int i = 0; i < n; ++i)
{
cin>>arr[i].second;
}
for (int i = 0; i < n; ++i)
{
cin>>arr[i].first;
}
sort(arr.begin(), arr.end(), [&](pair<int,int> a, pair<int,int> b){
return (a.first-a.second)<(b.first-b.second);
});
int ans = 0;
for (int i = 0; i < tol(n); i++){
int crr = 0;
bool boolean=true;
for (int j = 0; j < n; j++){
if (tol(j)&i) continue;
if (crr>arr[j].first) boolean=false;
crr+=arr[j].second;
}
if (boolean) ans = max(ans,n-__builtin_popcountll(i));
}
cout<<ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2004 ms |
4184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |