답안 #976842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976842 2024-05-07T07:34:20 Z duckindog Sure Bet (CEOI17_sure) C++17
100 / 100
82 ms 3936 KB
#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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 392 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 392 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 82 ms 3520 KB Output is correct
18 Correct 70 ms 3516 KB Output is correct
19 Correct 68 ms 3516 KB Output is correct
20 Correct 63 ms 3396 KB Output is correct
21 Correct 71 ms 3776 KB Output is correct
22 Correct 79 ms 3644 KB Output is correct
23 Correct 68 ms 3528 KB Output is correct
24 Correct 68 ms 3344 KB Output is correct
25 Correct 71 ms 3376 KB Output is correct
26 Correct 70 ms 3936 KB Output is correct