제출 #1129790

#제출 시각아이디문제언어결과실행 시간메모리
1129790ttamxGym Badges (NOI22_gymbadges)C++20
9 / 100
183 ms10600 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 b[i]<b[j]||(b[i]==b[j]&&a[i]<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...