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>
using namespace std;
#define int long long
const int N = 5e5+5;
int n, x[N], l[N];
pair<int, int> s[N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x[i];
}
for (int i = 0; i < n; i++) {
cin >> l[i];
}
for (int i = 0; i < n; i++) {
s[i] = make_pair(x[i]+l[i], i);
}
sort(s, s+n);
int ans = 0;
int lvl = 0;
for (int i = 0; i < n; i++) {
int idx = s[i].second;
if (lvl <= l[idx]) {
ans++;
lvl += x[idx];
}
}
cout << ans << "\n";
}
# | 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... |