답안 #47794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47794 2018-05-07T09:30:16 Z Extazy Sure Bet (CEOI17_sure) C++17
100 / 100
95 ms 16932 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

const int N = 100007;

int n;
double a[N],b[N],ans;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i,j;

  scanf("%d", &n);
  for(i=1;i<=n;i++) {
    scanf("%lf %lf", &a[i], &b[i]);
  }

  sort(a+1,a+1+n);
  reverse(a+1,a+1+n);

  sort(b+1,b+1+n);
  reverse(b+1,b+1+n);

  for(i=1;i<=n;i++) {
    a[i]+=a[i-1];
    b[i]+=b[i-1];
  }

  ans=0.0;

  for(i=1;i<=n;i++) {
    j=(int)(lower_bound(b+1,b+1+n,a[i])-b);
    if(j>=1 && j<=n) ans=max(ans,min(a[i],b[j])-i-j);
  
    j=(int)(lower_bound(a+1,a+1+n,b[i])-a);
    if(j>=1 && j<=n) ans=max(ans,min(a[j],b[i])-i-j);
  }

  printf("%.4lf\n", ans);

  return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
sure.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lf %lf", &a[i], &b[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 3 ms 576 KB Output is correct
8 Correct 2 ms 648 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 3 ms 844 KB Output is correct
14 Correct 6 ms 844 KB Output is correct
15 Correct 4 ms 856 KB Output is correct
16 Correct 3 ms 872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 3 ms 576 KB Output is correct
8 Correct 2 ms 648 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 3 ms 768 KB Output is correct
13 Correct 3 ms 844 KB Output is correct
14 Correct 6 ms 844 KB Output is correct
15 Correct 4 ms 856 KB Output is correct
16 Correct 3 ms 872 KB Output is correct
17 Correct 89 ms 3708 KB Output is correct
18 Correct 90 ms 5204 KB Output is correct
19 Correct 92 ms 6588 KB Output is correct
20 Correct 89 ms 7968 KB Output is correct
21 Correct 95 ms 9596 KB Output is correct
22 Correct 90 ms 11076 KB Output is correct
23 Correct 89 ms 12320 KB Output is correct
24 Correct 91 ms 13688 KB Output is correct
25 Correct 88 ms 15184 KB Output is correct
26 Correct 93 ms 16932 KB Output is correct