답안 #732281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
732281 2023-04-28T23:52:31 Z tvladm2009 Sure Bet (CEOI17_sure) C++17
100 / 100
125 ms 8336 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int) 2e5 + 7;
const ld INF = (ld) 1e9;
ld a[N], b[N];

ld f(int type1, int total) {
  return min(a[type1], b[total - type1]) - total;
}

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  reverse(b + 1, b + n + 1);
  for (int i = 1; i <= 2 * n; i++) {
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= 2 * n; i++) {
    b[i] += b[i - 1];
  }
  ld ret = 0;
  for (int i = 1; i <= 2 * n; i++) {
    int low = 0, high = min(n, i), sol = 0;
    while (low <= high) {
      int mid = (low + high) / 2;
      if (f(mid, i) >= f(mid - 1, i)) {
        sol = mid;
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    ret = max(ret, f(sol, i));
  }
  cout << setprecision(4) << fixed << ret;
  return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 113 ms 6456 KB Output is correct
18 Correct 115 ms 6476 KB Output is correct
19 Correct 115 ms 6576 KB Output is correct
20 Correct 117 ms 7940 KB Output is correct
21 Correct 121 ms 8268 KB Output is correct
22 Correct 117 ms 7884 KB Output is correct
23 Correct 114 ms 7932 KB Output is correct
24 Correct 117 ms 7832 KB Output is correct
25 Correct 115 ms 7892 KB Output is correct
26 Correct 125 ms 8336 KB Output is correct