Submission #115062

# Submission time Handle Problem Language Result Execution time Memory
115062 2019-06-05T04:00:39 Z IOrtroiii Sure Bet (CEOI17_sure) C++14
100 / 100
94 ms 3812 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
   int n;
   scanf("%d", &n);
   priority_queue<double> qa;
   priority_queue<double> qb;
   for (int i = 1; i <= n; ++i) {
      double a, b;
      scanf("%lf %lf", &a, &b);
      qa.emplace(a);
      qb.emplace(b);
   }
   double sa = 0.0;
   double sb = 0.0;
   double ans = 0.0;
   for (int i = 1; i <= 2 * n; ++i) {
      if (sa < sb) {
         if (qa.empty()) break;
         sa += qa.top();
         qa.pop();
      } else {
         if (qb.empty()) break;
         sb += qb.top();
         qb.pop();
      }
      ans = max(ans, min(sa, sb) - 1.0 * i);
   }
   cout << fixed << setprecision(4) << ans << endl;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:7:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &n);
    ~~~~~^~~~~~~~~~
sure.cpp:12:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%lf %lf", &a, &b);
       ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 82 ms 3556 KB Output is correct
18 Correct 79 ms 3516 KB Output is correct
19 Correct 80 ms 3528 KB Output is correct
20 Correct 76 ms 3428 KB Output is correct
21 Correct 83 ms 3808 KB Output is correct
22 Correct 85 ms 3296 KB Output is correct
23 Correct 82 ms 3552 KB Output is correct
24 Correct 80 ms 3428 KB Output is correct
25 Correct 76 ms 3424 KB Output is correct
26 Correct 94 ms 3812 KB Output is correct