# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
129951 | arnold518 | Sure Bet (CEOI17_sure) | C++14 | 78 ms | 3596 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
int N;
double A[MAXN+10], B[MAXN+10], ans;
int main()
{
int i, j;
scanf("%d", &N);
for(i=1; i<=N; i++) scanf("%lf%lf", &A[i], &B[i]);
sort(A+1, A+N+1, greater<double>());
sort(B+1, B+N+1, greater<double>());
int pa=1, pb=1;
double asum=0, bsum=0;
while(pa<=N || pb<=N)
{
if(pb>N || (pa<=N && asum<bsum)) asum+=A[pa++];
else bsum+=B[pb++];
ans=max(ans, min(asum-pa-pb+2, bsum-pa-pb+2));
}
printf("%.4f", 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... |