Submission #1123462

#TimeUsernameProblemLanguageResultExecution timeMemory
1123462AvianshGym Badges (NOI22_gymbadges)C++20
9 / 100
155 ms8472 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; array<int,3>arr[n]; for(int i = 0;i<n;i++){ cin >> arr[i][1]; } for(int i = 0;i<n;i++){ cin >> arr[i][2]; } //sum,x,l for(int i = 0;i<n;i++){ arr[i][0]=arr[i][1]+arr[i][2]; } sort(arr,arr+n); int ans = 0; long long sm = 0; priority_queue<int>pq; for(int i = 0;i<n;i++){ while(sm>arr[i][2]){ int neg = pq.top(); sm-=neg; pq.pop(); } sm+=arr[i][1]; pq.push(arr[i][1]); ans=max(ans,(int)pq.size()); } cout << ans; 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...