Submission #886523

#TimeUsernameProblemLanguageResultExecution timeMemory
886523Kel_MahmutGym Badges (NOI22_gymbadges)C++14
9 / 100
351 ms27452 KiB
#include <bits/stdc++.h> #define pb push_back #define all(aa) aa.begin(), aa.end() using namespace std; typedef long long ll; int main(){ int n; cin >> n; vector<ll> L(n), X(n); for(int i = 0; i < n; i++) cin >> X[i]; for(int i = 0; i < n; i++) cin >> L[i]; vector<pair<ll, ll>> G(n); for(int i = 0; i < n; i++){ G[i] = make_pair(L[i], X[i]); } sort(all(G)); priority_queue<ll> vals; ll score = 0, ans = 0; for(int i = 0; i < n; i++){ auto [Li, Xi] = G[i]; if(score <= Li){ vals.push(Xi); score += Xi; ans++; } else if(vals.top() > Xi){ score -= vals.top(); vals.pop(); score += Xi; vals.push(Xi); } } cout << ans << endl; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:25:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |   auto [Li, Xi] = G[i];
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...