답안 #161576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161576 2019-11-03T07:45:42 Z shayan_p Sure Bet (CEOI17_sure) C++14
100 / 100
118 ms 3580 KB
// Remember...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

double arr[2*maxn];
double a[maxn], b[maxn];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n; cin>>n;
    for(int i=0;i<n;i++)
	cin>>a[i]>>b[i];
    sort(a,a+n), sort(b,b+n);
    reverse(a,a+n), reverse(b,b+n);
    for(int i=0;i<n;i++)
	a[i]+= i==0 ? 0 : a[i-1], b[i]+= i==0 ? 0 : b[i-1], arr[2*i]=a[i], arr[2*i+1]= b[i];
    sort(arr,arr+2*n);
    int pta=0, ptb=0;
    double ans=0;
    for(int i=0;i<2*n;i++){
	while(pta<n && arr[i]>a[pta]) pta++;
	while(ptb<n && arr[i]>b[ptb]) ptb++;
	if(arr[i] > min(a[n-1],b[n-1])) break;
	ans=max(ans, arr[i] -pta -ptb -2);
    }
    return cout<<setprecision(4)<<fixed<<ans<<endl,0;
}
// Deathly mistakes:
//  * Read the problem carefully.
//  * Check maxn.
//  * Overflows.


// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 380 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 5 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 380 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 420 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 380 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 380 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 420 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 348 KB Output is correct
15 Correct 3 ms 380 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 104 ms 3432 KB Output is correct
18 Correct 107 ms 3496 KB Output is correct
19 Correct 118 ms 3548 KB Output is correct
20 Correct 108 ms 3576 KB Output is correct
21 Correct 112 ms 3536 KB Output is correct
22 Correct 105 ms 3580 KB Output is correct
23 Correct 105 ms 3576 KB Output is correct
24 Correct 105 ms 3492 KB Output is correct
25 Correct 110 ms 3548 KB Output is correct
26 Correct 118 ms 3448 KB Output is correct