Submission #380708

#TimeUsernameProblemLanguageResultExecution timeMemory
380708MladenPSure Bet (CEOI17_sure)C++17
100 / 100
92 ms3820 KiB
#include <bits/stdc++.h> #define MAXN 100010 using namespace std; double a[MAXN], b[MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; for(int i = 1; i <= N; i++) { cin >> a[i] >> b[i]; } sort(a+1, a+1+N); reverse(a+1, a+1+N); sort(b+1, b+1+N); reverse(b+1, b+1+N); double rez = 0; int idxa = 1, idxb = 1; double suma = 0, sumb = 0; for(int i = 1; i <= 2*N; i++) { if(idxa == N+1) { sumb += b[idxb]; idxb++; } else if(idxb == N+1) { suma += a[idxa]; idxa++; } else { if(suma > sumb) { sumb += b[idxb]; idxb++; } else { suma += a[idxa]; idxa++; } } rez = max(rez, min(suma-i, sumb-i)); } cout << fixed << setprecision(4) << rez << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...