제출 #1218329

#제출 시각아이디문제언어결과실행 시간메모리
1218329JhoZzelGym Badges (NOI22_gymbadges)C++20
0 / 100
95 ms6332 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second using ll = long long; const ll INF = 1e16; int main() { cin.tie(0) -> sync_with_stdio(0); int n; cin >> n; vector<pair<int,int>> a(n); for (int i = 0; i < n; i++) cin >> a[i].ss; for (int i = 0; i < n; i++) cin >> a[i].ff; sort(a.begin(), a.end(), [&](pair<int,int> x, pair<int,int> y) { return x.ff + x.ss < y.ff + y.ss; }); ll sa = 0; priority_queue<int> pq; for (int i = 0; i < n; i++) { if (pq.empty() or sa <= a[i].ff) { sa += a[i].ss; pq.push(a[i].ff); } else if (a[i].ss <= pq.top()) { sa += a[i].ss - pq.top(); pq.pop(); pq.push(a[i].ff); } } cout << pq.size() << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...