# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303930 | peuch | Sure Bet (CEOI17_sure) | C++17 | 74 ms | 3576 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int n;
double a[MAXN], b[MAXN];
double bWin, aWin, cost;
double ans;
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%lf %lf", &a[i], &b[i]);
sort(a + 1, a + 1 + n);
sort(b + 1, b + 1 + n);
int aID = n, bID = n;
while(aID > 0 && bID > 0){
cost--;
if(aWin < bWin || (aWin == bWin && a[aID] > b[bID]))
aWin += a[aID--];
else
bWin += b[bID--];
ans = max(ans, min(aWin, bWin) + cost);
}
while(aID > 0){
cost--;
aWin += a[aID--];
ans = max(ans, min(aWin, bWin) + cost);
}
while(bID > 0){
cost--;
bWin += b[bID--];
ans = max(ans, min(aWin, bWin) + cost);
}
printf("%0.4lf", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |