답안 #137076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137076 2019-07-27T04:19:43 Z thebes Sure Bet (CEOI17_sure) C++14
100 / 100
102 ms 3576 KB
#include <bits/stdc++.h>
using namespace std;

const double eps = 1e-5;
const int MN = 1e5+5;
double lo, hi, a[MN], b[MN], aa, bb, cc;
int n, i, l, r;

int main(){
    for(scanf("%d",&n),i=1;i<=n;i++){
        scanf("%lf%lf",&a[i],&b[i]);
    }
    sort(a+1,a+n+1,[](double i,double j){return i>j;});
    sort(b+1,b+n+1,[](double i,double j){return i>j;});
    lo=0; hi=2e9;
    while(lo+eps<hi){
        double m=(lo+hi)/2;
        aa=bb=cc=0;
        l=r=0;
        while(1){
            if(aa<m){
                if(l==n) break;
                aa += a[++l];
                aa-=1;
                bb-=1;
            }
            else if(bb<m){
                if(r==n) break;
                bb += b[++r];
                aa-=1;
                bb-=1;
            }
            else break;
        }
        if(aa>=m&&bb>=m) lo=m+eps;
        else hi=m;
    }
    printf("%.4lf\n",lo);
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:10:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d",&n),i=1;i<=n;i++){
         ~~~~~~~~~~~~~~^~~~
sure.cpp:11:14: 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 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 380 KB Output is correct
17 Correct 88 ms 3168 KB Output is correct
18 Correct 89 ms 3320 KB Output is correct
19 Correct 94 ms 3192 KB Output is correct
20 Correct 94 ms 3196 KB Output is correct
21 Correct 101 ms 3576 KB Output is correct
22 Correct 88 ms 3448 KB Output is correct
23 Correct 89 ms 3324 KB Output is correct
24 Correct 96 ms 3288 KB Output is correct
25 Correct 91 ms 3320 KB Output is correct
26 Correct 102 ms 3576 KB Output is correct