Submission #976842

#TimeUsernameProblemLanguageResultExecution timeMemory
976842duckindogSure Bet (CEOI17_sure)C++17
100 / 100
82 ms3936 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 100'000 + 10;
int n;

int32_t main() { 
  cin.tie(0)->sync_with_stdio(0);

  cin >> n;
  
  priority_queue<double> qa, qb;
  while (n--) { 
    double a, b; cin >> a >> b;
    qa.push(a); qb.push(b);
  }

  double first = 0, second = 0, answer = 0;
  int cnt = 0;
  while (true) {
    if (first <= second && qa.size()) { 
      first += qa.top(); qa.pop();
      cnt += 1;
    } else if (second <= first && qb.size()) { 
      second += qb.top(); qb.pop();
      cnt += 1;
    } else break;
    answer = max(answer, min(first, second) - cnt);
  }

  cout << setprecision(4) << fixed << answer << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...