This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 << dem << '\n';
}
}
cout << dem1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |