Submission #169696

#TimeUsernameProblemLanguageResultExecution timeMemory
169696apostoldaniel854Sure Bet (CEOI17_sure)C++14
100 / 100
104 ms3832 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define dbg(x) cerr << #x << " " << x << "\n" const int N = 1e5; double a[1 + N], b[1 + N]; int main () { ios::sync_with_stdio (false); cin.tie (0); cout.tie (0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort (a + 1, a + n + 1); reverse (a + 1, a + n + 1); sort (b + 1, b + n + 1); reverse (b + 1, b + n + 1); double suma = 0, sumb = 0; double ans = 0; int cura = 0, curb = 0; for (int i = 1; i <= n * 2; i++) { if ((suma < sumb || curb == n) && cura != n) suma += a[++cura]; else sumb += b[++curb]; ans = max (ans, min (suma, sumb) - i); } cout << fixed << setprecision (4) << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...