답안 #1002093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1002093 2024-06-19T09:52:29 Z asdasdqwer Sure Bet (CEOI17_sure) C++14
100 / 100
137 ms 8276 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t
#define ld long double
#define pii array<int,2>

vector<ld> prefSum(vector<ld> &a) {
  vector<ld> p(a.size());
  p[0] = a[0];
  for (int i=1;i<(int)a.size();i++) p[i]=p[i-1]+a[i];
  return p;
}

signed main() {
  int n;cin>>n;
  vector<ld> a(n), b(n);
  for (int i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  }

  sort(a.begin(), a.end(), greater<ld>());
  sort(b.begin(), b.end(), greater<ld>());

  vector<ld> pa = prefSum(a), pb = prefSum(b);

  ld l = 0, r = 1e9;

  while (abs(l - r) >= 0.000001) {
    ld m = (l+r) / 2.0;
    bool pos = false;
    for (int i=0;i<n;i++) {
      ld wn = (pa[i] - (ld)(i+1)) - m;
      if (wn <= 0.0) continue;
      wn = floor(wn);
      int k = (int)wn;
      if (k <= 0) continue;
      k = min(k, n);
      ld pw = pb[k-1] - (ld)(i+1+k);
      if (pw >= m) {
        pos = true;
        break;
      }
    }

    if (pos) {
      l = m;
    }

    else {
      r = m;
    }
  }

  printf("%.4lf\n", (double)l);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 496 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 1 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 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 496 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 127 ms 7900 KB Output is correct
18 Correct 137 ms 8272 KB Output is correct
19 Correct 132 ms 8044 KB Output is correct
20 Correct 124 ms 8020 KB Output is correct
21 Correct 107 ms 8276 KB Output is correct
22 Correct 133 ms 8028 KB Output is correct
23 Correct 126 ms 7900 KB Output is correct
24 Correct 121 ms 7900 KB Output is correct
25 Correct 124 ms 7916 KB Output is correct
26 Correct 96 ms 8272 KB Output is correct