Submission #886730

#TimeUsernameProblemLanguageResultExecution timeMemory
886730aykhnSure Bet (CEOI17_sure)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> // author : aykhn using namespace std; typedef long long ll; #define pb push_back #define ins insert #define mpr make_pair #define all(v) v.begin(), v.end() #define bpc __builtin_popcount #define bpcll __builtin_popcountll #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define int ll #define infll 0x3F3F3F3F3F3F3F3F #define inf 0x3F3F3F3F void _() { int n; cin >> n; int a[n], b[n]; int res = -infll; for (int i = 0; i < n; i++) { double x, y; cin >> x >> y; a[i] = x * 10000 + 0.5; b[i] = y * 10000 + 0.5; } sort(a, a + n, greater<int> ()); sort(b, b + n, greater<int> ()); int i = 0; int j = 0; int sum1 = 0, sum2 = 0; while (i < n || j < n) { if (i == n) sum2 += b[j++]; else if (j == n) sum1 += a[i++]; else if (sum1 <= sum2) sum1 += a[i++]; else sum2 += b[j++]; res = max(res, min(sum2, sum1) - i * 10000 - j * 10000); } cout << res/10000 << '.' << res%10000 << '\n'; } signed main() { int t = 1; // cin >> t; for (int tt = 0; tt < t; tt++) { _(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...