Submission #865472

# Submission time Handle Problem Language Result Execution time Memory
865472 2023-10-24T09:00:08 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
66 ms 6860 KB
/*
   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
      '# ------- #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))
    art by - Vinni01 / luchi abi
 
    cout << fixed << setprecision(6) << x;
    freopen ( "sum.in", "r", stdin )
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization("unroll-loops")
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std ;
#define ll int
#define ld double
#define ff first
#define ss second
#define pb push_back 
#define pf push_front
#define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0)
#define sz size
#define ins insert
#define new jweijofdg
const ll N = 2e6 + 111 ;
const ll k = 400 ;
ld a[ N ], b[ N ] ;
ld p[ N ], s[ N ] ;
ld ans = 0.00 ;
signed main()
{
    UseOFF ;
    ll n, m ;
    cin >> n ;
    for( int i = 1 ; i <= n ; i++ )
    {
    	cin >> a[ i ] >> b[ i ] ;
    }
    sort( a + 1, a + n + 1 ) ;
    sort( b + 1, b + n + 1 ) ;
    reverse( a + 1, a + n + 1 ) ;
    reverse( b + 1, b + n + 1 ) ;
    ll l1 = 1,l2 = 1 ; 
    ld x = 0, y = 0 ;
    while( l1 <= n || l2 <= n )
    {
    	//cout << l1 << " " << l2 << " || " << x << " " << y << " " << ans << '\n' ;
    	if( l2 == n + 1 || x <= y )
    	{
    		x += a[ l1 ] ;
    		l1++ ;
    	}
    	else if( l1 == n + 1 || y < x )
    	{
    		y += b[ l2 ] ;
    		l2++ ;
    	}
    	ld d = min( x, y ) - ( l1 + l2 - 2 ) ;
    	ans = max( ans, d ) ; 
    }
    printf("%.4lf",(double)ans);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:67:11: warning: unused variable 'm' [-Wunused-variable]
   67 |     ll n, m ;
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 4 ms 4444 KB Output is correct
5 Correct 4 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 4 ms 4444 KB Output is correct
5 Correct 4 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 4 ms 4440 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 4 ms 4572 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 4 ms 4444 KB Output is correct
16 Correct 7 ms 4824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 4 ms 4444 KB Output is correct
5 Correct 4 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 4 ms 4440 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 4 ms 4572 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 4 ms 4444 KB Output is correct
16 Correct 7 ms 4824 KB Output is correct
17 Correct 57 ms 6620 KB Output is correct
18 Correct 58 ms 6596 KB Output is correct
19 Correct 54 ms 6492 KB Output is correct
20 Correct 57 ms 6604 KB Output is correct
21 Correct 57 ms 6492 KB Output is correct
22 Correct 66 ms 6492 KB Output is correct
23 Correct 59 ms 6492 KB Output is correct
24 Correct 54 ms 6488 KB Output is correct
25 Correct 57 ms 6492 KB Output is correct
26 Correct 61 ms 6860 KB Output is correct