답안 #697920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697920 2023-02-11T10:56:57 Z dattranxxx Sure Bet (CEOI17_sure) C++11
100 / 100
90 ms 5168 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e5 + 5;
ld a[N], b[N];
int n;

int main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> a[i] >> b[i];
  sort(a + 1, a + n + 1, greater<ld>());
  sort(b + 1, b + n + 1, greater<ld>());
  for (int i = 1; i <= n; ++i)
    a[i] += a[i - 1], b[i] += b[i - 1];
  ld res = 0.0;
  for (int i = 1, j = 1; i <= n; ++i) {
    while (j <= n && b[j] < a[i]) j++;
    if (j <= n) res = max(res, a[i] - i - j);
  }
  for (int i = 1, j = 1; i <= n; ++i) {
    while (j <= n && a[j] < b[i]) j++;
    if (j <= n) res = max(res, b[i] - i - j);
  }
  cout << fixed << setprecision(4) << res;
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 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 1 ms 456 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 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 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 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 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 1 ms 456 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 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 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 85 ms 4812 KB Output is correct
18 Correct 86 ms 4812 KB Output is correct
19 Correct 90 ms 4808 KB Output is correct
20 Correct 79 ms 4812 KB Output is correct
21 Correct 87 ms 5068 KB Output is correct
22 Correct 79 ms 4812 KB Output is correct
23 Correct 81 ms 4856 KB Output is correct
24 Correct 85 ms 4944 KB Output is correct
25 Correct 81 ms 4752 KB Output is correct
26 Correct 85 ms 5168 KB Output is correct