#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k,ans=0;
cin>>n>>k;
/*int r[n][k],u[n][k];
for(int i=0;i<n;i++)
for(int j=0;j<k;j++)
cin>>r[i][j];
for(int i=0;i<n;i++)
for(int j=0;j<k;j++)
cin>>u[i][j];
for(int i=0;i<k;i++)
if(r[0][i]>0)
cout<<0,exit(0);
cout<<1;*/
vector<pair<long long,long long>>ru;
long long r[n],u[n];
for(int i=0;i<n;i++)cin>>r[i];
for(int i=0;i<n;i++)cin>>u[i];
for(int i=0;i<n;i++)
ru.push_back({r[i],u[i]});
sort(ru.begin(),ru.end());
long long p=0;
for(int i=0;i<n;i++)
{
if(ru[i].first<=p)
{
ans++;
p+=ru[i].second;
continue;
}
else break;
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
6 ms |
1116 KB |
Output is correct |
4 |
Correct |
61 ms |
5576 KB |
Output is correct |
5 |
Correct |
51 ms |
5268 KB |
Output is correct |
6 |
Correct |
562 ms |
47940 KB |
Output is correct |
7 |
Correct |
530 ms |
46632 KB |
Output is correct |
8 |
Correct |
598 ms |
48316 KB |
Output is correct |
9 |
Correct |
534 ms |
47932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |