Submission #1264631

#TimeUsernameProblemLanguageResultExecution timeMemory
1264631minggaSure Bet (CEOI17_sure)C++20
100 / 100
54 ms2228 KiB
// Author: caption_mingle #include "bits/stdc++.h" using namespace std; #define ln "\n" #define pb push_back #define fi first #define se second #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) #define ll long long const int mod = 1e9 + 7; const int inf = 2e9; int n; signed main() { cin.tie(0) -> sync_with_stdio(0); #define task "" if(fopen(task ".INP", "r")) { freopen(task ".INP", "r", stdin); freopen(task ".OUT", "w", stdout); } cin >> n; priority_queue<double> q1, q2; for(int i = 1; i <= n; i++) { double a, b; cin >> a >> b; q1.push(a); q2.push(b); } double cur1 = 0, cur2 = 0; double ans = 0; for(int i = 1; i <= 2 * n; i++) { if(cur1 < cur2) { if(q1.empty()) break; cur1 += q1.top() - 1; q1.pop(); cur2 -= 1; } else { if(q2.empty()) break; cur2 += q2.top() - 1; q2.pop(); cur1 -= 1; } ans = max(ans, min(cur1, cur2)); } cout << setprecision(4) << fixed; cout << ans << ln; cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC; }

Compilation message (stderr)

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