Submission #311258

#TimeUsernameProblemLanguageResultExecution timeMemory
311258biggSure Bet (CEOI17_sure)C++14
100 / 100
78 ms3580 KiB
#include<bits/stdc++.h> using namespace std; typedef double ll; const int MAXN = 1e5 + 10; ll prefa[MAXN], prefb[MAXN], a[MAXN], b[MAXN]; int n; double cura = 0, curb = 0; int main(){ scanf("%d", &n ); for(int i = 0; i < n; i++){ scanf("%lf %lf", &a[i], &b[i]); } sort(a , a + n); sort(b , b + n); reverse(a, a + n); reverse(b, b + n); double ans = 0; int it1 = 0, it2 = 0; for(int i = 0; i < 2*n; i++){ if(cura >= curb && it2 < n) curb += b[it2], it2++; else if(cura < curb && it1 < n) cura += a[it1], it1++; ans = max(ans, min(cura, curb) - i - 1); } printf("%.4lf\n", ans); }

Compilation message (stderr)

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