Submission #868391

#TimeUsernameProblemLanguageResultExecution timeMemory
868391lovrotSure Bet (CEOI17_sure)C++17
100 / 100
72 ms5208 KiB
#include <algorithm> #include <cstdio> #include <vector> using namespace std; typedef long double ld; const int N = 1e5 + 10; int n; ld A[N], B[N]; ld solve() { ld ret = 0, sum = 0, _sum = 0; for(int i = 0, j = 0; i < n; ++i) { sum += A[i]; for(; j < n && _sum < sum; ++j) _sum += B[j]; if(j == n && _sum < sum) break; ret = max(ret, sum - (ld) i - (ld) j - 1.0); } return ret; } int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) scanf("%LF%LF", A + i, B + i); sort(A, A + n, [](ld a, ld b) { return a > b; }); sort(B, B + n, [](ld a, ld b) { return a > b; }); ld ans = solve(); swap(A, B); ans = max(ans, solve()); printf("%.4lf\n", (double) ans); return 0; }

Compilation message (stderr)

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