제출 #1129792

#제출 시각아이디문제언어결과실행 시간메모리
1129792ttamxGym Badges (NOI22_gymbadges)C++20
100 / 100
189 ms10536 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector<int> a(n),b(n),ord(n); for(auto &x:a)cin >> x; for(auto &x:b)cin >> x; iota(ord.begin(),ord.end(),0); sort(ord.begin(),ord.end(),[&](int i,int j){ return make_tuple(a[i]+b[i],b[i],a[i])<make_tuple(a[j]+b[j],b[j],a[j]); }); priority_queue<ll> pq; ll sum=0; for(int i:ord){ pq.emplace(a[i]); sum+=a[i]; if(sum>b[i]+a[i]){ sum-=pq.top(); pq.pop(); } } cout << pq.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...