Submission #129951

# Submission time Handle Problem Language Result Execution time Memory
129951 2019-07-13T15:22:21 Z arnold518 Sure Bet (CEOI17_sure) C++14
100 / 100
78 ms 3596 KB
#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

sure.cpp: In function 'int main()':
sure.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
sure.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
sure.cpp:18:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%lf%lf", &A[i], &B[i]);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 73 ms 3192 KB Output is correct
18 Correct 74 ms 3192 KB Output is correct
19 Correct 76 ms 3192 KB Output is correct
20 Correct 74 ms 3324 KB Output is correct
21 Correct 77 ms 3596 KB Output is correct
22 Correct 73 ms 3320 KB Output is correct
23 Correct 74 ms 3292 KB Output is correct
24 Correct 78 ms 3320 KB Output is correct
25 Correct 74 ms 3320 KB Output is correct
26 Correct 77 ms 3576 KB Output is correct