Submission #1026994

#TimeUsernameProblemLanguageResultExecution timeMemory
1026994vjudge1Sure Bet (CEOI17_sure)C++14
100 / 100
74 ms3564 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> using namespace std; #define name "aaaaaa" using ll = long long; using pii = pair<int, int>; using ld = long double; void file(){ ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } } const int maxn = 1e5 + 5; ld a[maxn], b[maxn]; void solve (){ int n; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; } sort(a + 1, a + n + 1); sort(b + 1, b + n + 1); ld suma = 0, sumb = 0, ans = 0; int p1 = n, p2 = n; while(1){ if(p1 == -1 || p2 == -1) break; if(suma < sumb){ suma += a[p1]; p1--; }else{ sumb += b[p2]; p2--; } ans = max(ans, min(suma, sumb) - (n - p1) - (n - p2)); } cout << fixed << setprecision(4) << ans; } int main(){ file(); solve(); }

Compilation message (stderr)

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