Submission #161807

#TimeUsernameProblemLanguageResultExecution timeMemory
161807dantoh000Sure Bet (CEOI17_sure)C++14
100 / 100
76 ms2936 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    scanf("%d",&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.1;
        y = (10000)*y + 0.1;
        a[i] = x, b[i] = y;
    }
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    int ida = 0, idb = 0;
    ll suma = 0, sumb = 0;
    ll ans = 0;
    for (int i = 1; i <= 2*n; i++){
        //printf("%d %d\n",ida,idb);
        if ((suma < sumb || idb == n) && ida != n){
            suma += a[ida];
            ida++;
        }
        else{
            sumb += b[idb];
            idb++;
        }
        //printf("%d %lld %lld\n",i,suma,sumb);
        ans = max(ans,max(0ll,min(suma,sumb)-10000ll*i));
    }
    double actans = ((double)ans)/10000;
    printf("%.4f",actans);
}

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...