Submission #65777

#TimeUsernameProblemLanguageResultExecution timeMemory
65777naderjemelSure Bet (CEOI17_sure)C++14
100 / 100
101 ms17072 KiB
#include <bits/stdc++.h> using namespace std; const long long INF=2e9; int main(){ int n; scanf("%d",&n); vector<double> as,bs; for(int i=0;i<n;i++){ double a,b; scanf("%lf %lf",&a,&b); as.push_back(a); bs.push_back(b); } sort(as.begin(),as.end()); sort(bs.begin(),bs.end()); reverse(as.begin(),as.end()); reverse(bs.begin(),bs.end()); int i=0,j=0; double rs=0.0,us=0.0; double nowa=0,nowb=0; while(i<n || j<n){ if(i<n && j<n){ if(nowa<=nowb && i<n){ nowa+=as[i]; i++; us+=1.0; } else if(j<n){ nowb+=bs[j]; j++; us+=1.0; } } else if(i<n){ nowa+=as[i]; i++; us+=1.0; } else{ nowb+=bs[j]; j++; us+=1.0; } rs=max(rs,min(nowa-us,nowb-us)); } printf("%.4lf\n", (double)rs); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:5:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d",&n);
         ~~~~~^~~~~~~~~
sure.cpp:8:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   double a,b; scanf("%lf %lf",&a,&b);
               ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...