Submission #303929

#TimeUsernameProblemLanguageResultExecution timeMemory
303929peuchSure Bet (CEOI17_sure)C++17
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 100010; int n; double a[MAXN], b[MAXN]; double bWin, aWin, cost; double ans; int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%lf %lf", &a[i], &b[i]); sort(a + 1, a + 1 + n); sort(b + 1, b + 1 + n); int aID = n, bID = n; while(aID > 0 && bID > 0){ cost--; if(aWin < bWin || (aWin == bWin && a[aID] > b[bID])) aWin += a[aID--]; else bWin += b[bID--]; ans = max(ans, min(aWin, bWin) + cost); } printf("%0.4lf", ans); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   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...