Submission #151213

#TimeUsernameProblemLanguageResultExecution timeMemory
151213karmaSure Bet (CEOI17_sure)C++14
100 / 100
155 ms5268 KiB
#include <bits/stdc++.h> #define ld long double #define pb emplace_back #define mp make_pair #define fi first #define se second using namespace std; const int N = int(1e5) + 1; const ld eps = 1e-6; int n; ld a[N], b[N], res = 0, cur; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); if(fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1, greater<ld>()), sort(b + 1, b + n + 1, greater<ld>()); for(int i = 1; i <= n; ++i) a[i] += a[i - 1], b[i] += b[i - 1]; int low, high, mid; ld x, x1; for(int i = 1; i <= n; ++i) { low = 1, high = n; cur = min(a[i] - i - 1, b[1] - i - 1); while(low <= high) { mid = (low + high) >> 1; x = min(a[i] - i - mid, b[mid] - i - mid); x1 = min(a[i] - i - mid + 1, b[mid - 1] - i - mid + 1); cur = max({cur, x, x1}); if(x >= x1) low = mid + 1; else high = mid - 1; } res = max(res, cur); } cout << fixed << setprecision(4) << res; }

Compilation message (stderr)

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