Submission #1123483

#TimeUsernameProblemLanguageResultExecution timeMemory
1123483AvianshGym Badges (NOI22_gymbadges)C++20
100 / 100
151 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++){ if(sm>arr[i][2]){ int neg = pq.top(); if(neg>arr[i][1]&&sm-neg<=arr[i][2]){ sm-=neg; pq.pop(); } else{ continue; } } 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...