Submission #98925

#TimeUsernameProblemLanguageResultExecution timeMemory
98925arman_ferdousSure Bet (CEOI17_sure)C++17
100 / 100
94 ms3684 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5+10; int n; double a[N], b[N]; 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); int p1 = n-1, p2 = n-1; double ans = 0, A = 0, B = 0; for(int i = 1; i <= (n<<1); i++) { if(p1 < 0) B += b[p2--]; else if(p2 < 0) A += a[p1--]; else if(B > A) A += a[p1--]; else B += b[p2--]; ans = max(ans, min(A - i, B - i)); } printf("%.4lf\n", ans); return 0; }

Compilation message (stderr)

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