Submission #160256

# Submission time Handle Problem Language Result Execution time Memory
160256 2019-10-26T13:53:26 Z Akashi Sure Bet (CEOI17_sure) C++14
0 / 100
8 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

int n;
double a[100005], b[100005];
int main()
{
//    freopen("1.in", "r", stdin);

    scanf("%d", &n);
    for(int i = 1; i <= n ; ++i) scanf("%lf %lf", &a[i], &b[i]);

    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);

    double st = 0, dr = 1e9;
    int pasi = 69;
    while(pasi--){
        double mij = (st + dr) / 2;

        int i = n, j = n, cost = 0;
        double sum1 = 0, sum2 = 0;
        while(i >= 0 && j >= 0){
            if(sum1 - cost >= mij && sum2 - cost >= mij) break ;

            if(sum1 - cost < mij){
                ++cost;
                sum1 += a[i--];
            }
            else{
                ++cost;
                sum2 += b[j--];
            }
        }

        if(sum1 - cost < mij || sum2 - cost < mij) dr = mij;
        else st = mij;
    }

    printf("%f", st);

    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sure.cpp:11:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n ; ++i) scanf("%lf %lf", &a[i], &b[i]);
                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -