Submission #1316650

#TimeUsernameProblemLanguageResultExecution timeMemory
1316650levGym Badges (NOI22_gymbadges)C++20
24 / 100
117 ms12424 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second #define pii pair<int, int> #define all(a) a.begin(), a.end() using namespace std; #ifdef LOCAL #include "C:\Users\Dell\Downloads\template\template\icpc-notebook\Utilities\debug.h" #else #define debug(...) 42 #endif const int mn = 5e5 + 5, mod = 1e9 + 7, inf = 2e9; int n; array <int, 2> a[mn]; bool cmp(array <int, 2> x, array<int, 2> y){ return x[0] + x[1] < y[0] + y[1]; } void solve() { cin >> n; for(int i = 1; i <= n; i++) cin >> a[i][0]; for(int i = 1; i <= n; i++) cin >> a[i][1]; sort(a + 1, a + n + 1, cmp); int cur = 0, ans = 0; priority_queue <int> pq; for(int i = 1; i <= n; i++){ debug(cur, a[i][0], a[i][1]); if(pq.size()) debug(pq.top()); if(cur <= a[i][1]){ pq.push(a[i][0]); cur += a[i][0], ans ++; } else if(i > 1 && a[i][0] < pq.top() && cur - pq.top() + a[i][0] <= a[i][1]){ cur -= pq.top(), cur += a[i][0]; pq.pop(); pq.push(a[i][0]); } } cout << ans << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define task "Kawabata" if (fopen(task".INP", "r")) { freopen(task".INP", "r", stdin); freopen(task".OUT", "w", stdout); } int t = 1; // cin >> t; while (t--) solve(); return 0; } // Don't wanna lose anymore T_T // Never let me go - Kazuo Ishiguro

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(task".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(task".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...