Submission #161791

# Submission time Handle Problem Language Result Execution time Memory
161791 2019-11-04T12:17:17 Z dantoh000 Sure Bet (CEOI17_sure) C++14
0 / 100
2 ms 256 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
main(){
    int n;
    scanf("%lld",&n);
    int a[n], b[n];
    for (int i = 0; i < n; i++){
        double x,y;
        scanf("%lf%lf",&x,&y);
        x = (10000)*x + 0.5;
        y = (10000)*y + 0.5;
        a[i] = x, b[i] = y;
    }
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    int ida = 0, idb = 0;
    int suma = 0, sumb = 0;
    int ans = 0;
    for (int i = 1; i <= 2*n; i++){
        if (ida != n && suma < sumb){
            suma += a[ida];
            ida++;
        }
        else{
            sumb += b[idb];
            idb++;
        }
        //printf("%lld %lld %lld\n",i,suma,sumb);
        ans = max(ans,min(suma,sumb)-10000*i);
    }
    printf("%.4lf",((long double)ans)/10000);
}

Compilation message

sure.cpp:4:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sure.cpp: In function 'int main()':
sure.cpp:32:44: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
     printf("%.4lf",((long double)ans)/10000);
                    ~~~~~~~~~~~~~~~~~~~~~~~~^
sure.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
sure.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf%lf",&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -