Submission #563699

#TimeUsernameProblemLanguageResultExecution timeMemory
563699tranxuanbachSure Bet (CEOI17_sure)C++17
100 / 100
76 ms2812 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define endl '\n' #define fi first #define se second #define For(i, l, r) for (auto i = (l); i < (r); i++) #define ForE(i, l, r) for (auto i = (l); i <= (r); i++) #define FordE(i, l, r) for (auto i = (l); i >= (r); i--) #define Fora(v, a) for (auto v: (a)) #define bend(a) (a).begin(), (a).end() #define isz(a) ((signed)(a).size()) using ll = long long; using ld = long double; using pii = pair <int, int>; using vi = vector <int>; using vpii = vector <pii>; using vvi = vector <vi>; const int N = 1e5 + 5; int n; int a[N], b[N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("KEK.inp", "r", stdin); // freopen("KEK.out", "w", stdout); cin >> n; ForE(i, 1, n){ double x, y; cin >> x >> y; a[i] = round(x * 10000); b[i] = round(y * 10000); } sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1); sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1); ll ans = 0; { ll suma = 0, sumb = 0; int idx = 0; ForE(i, 1, n){ suma += a[i]; while (idx + 1 <= n and sumb < suma){ idx++; sumb += b[idx]; } ans = max(ans, min(suma, sumb) - (ll)(i + idx) * 10000); } } { ll suma = 0, sumb = 0; int idx = 0; ForE(i, 1, n){ sumb += b[i]; while (idx + 1 <= n and suma < sumb){ idx++; suma += a[idx]; } ans = max(ans, min(suma, sumb) - (ll)(i + idx) * 10000); } } cout << fixed << setprecision(4) << (ld)ans / 10000 << endl; } /* ==================================================+ INPUT: | --------------------------------------------------| --------------------------------------------------| ==================================================+ OUTPUT: | --------------------------------------------------| --------------------------------------------------| ==================================================+ */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...