Submission #359763

# Submission time Handle Problem Language Result Execution time Memory
359763 2021-01-27T07:47:21 Z shahriarkhan Sure Bet (CEOI17_sure) C++14
100 / 100
175 ms 3820 KB
#include<bits/stdc++.h>
using namespace std ;

const long long c = 1e9 ;

int main()
{
    int n ;
    scanf("%d",&n) ;
    priority_queue<long long> a , b ;
    long long x = 0 , y = 0 , ans = 0 ;
    for(int i = 1 ; i <= n ; ++i)
    {
        double ad , bd ;
        cin>>ad>>bd ;
        long long ac = (ad*c) , bc = (bd*c) ;
        a.push(ac-c) , b.push(bc-c) ;
    }
    while(!a.empty())
    {
        x += a.top() , y -= c ;
        a.pop() ;
        while(!b.empty())
        {
            if(min(x-c,y+b.top())>=min(x,y))
            {
                x -= c , y += b.top() ;
                b.pop() ;
            }
            else break ;
        }
        ans = max(ans,min(x,y)) ;
    }
    long double p = ans , q = c ;
    cout<<fixed<<setprecision(4)<<p/q<<endl ;
    return 0 ;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 153 ms 3544 KB Output is correct
18 Correct 155 ms 3544 KB Output is correct
19 Correct 152 ms 3640 KB Output is correct
20 Correct 151 ms 3448 KB Output is correct
21 Correct 171 ms 3820 KB Output is correct
22 Correct 152 ms 3464 KB Output is correct
23 Correct 175 ms 3544 KB Output is correct
24 Correct 155 ms 3544 KB Output is correct
25 Correct 147 ms 3544 KB Output is correct
26 Correct 175 ms 3800 KB Output is correct