Submission #570721

#TimeUsernameProblemLanguageResultExecution timeMemory
570721radaiosm7Sure Bet (CEOI17_sure)C++98
100 / 100
85 ms3584 KiB
#include <bits/stdc++.h> using namespace std; int n, i, j; double a[100005]; double b[100005]; double ans, profa, profb; int main() { scanf("%d", &n); for (i=0; i < n; ++i) { scanf("%lf", &a[i]); scanf("%lf", &b[i]); } sort(a, a+n, greater<double>()); sort(b, b+n, greater<double>()); ans = 0.0; i = 0; j = 0; while (i < n && j < n) { profa -= 1.0; profb -= 1.0; if (profa < profb) profa += a[i++]; else profb += b[j++]; ans = max(ans, min(profa, profb)); } if (i == n) while (j < n) { profa -= 1.0; profb += b[j++]-1.0; ans = max(ans, min(profa, profb)); } else if (j == n) while (i < n) { profa += a[i++]-1.0; profb -= 1.0; ans = max(ans, min(profa, profb)); } printf("%.4lf\n", ans); return 0; }

Compilation message (stderr)

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