Submission #931448

#TimeUsernameProblemLanguageResultExecution timeMemory
931448vjudge1Gym Badges (NOI22_gymbadges)C++17
24 / 100
118 ms25536 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...