답안 #121156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
121156 2019-06-26T07:17:50 Z MvC Sure Bet (CEOI17_sure) C++11
0 / 100
2 ms 384 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "teams.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const ll nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,i,j,l,r,mid,rs;
double a[nmax],b[nmax],p[nmax],s[nmax],ans;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(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);
	for(i=1;i<=n;i++)p[i]=p[i-1]+a[i];
	for(i=1;i<=n;i++)s[i]=s[i-1]+b[i];
	for(i=1;i<=n;i++)
	{
		l=1,r=n;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(s[mid]>=p[i])rs=mid,r=mid-1;
			else l=mid+1;
		}
		ans=max(ans,p[i]-i-l);
		l=1,r=n;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(p[mid]>=s[i])rs=mid,r=mid-1;
			else l=mid+1;
		}
		ans=max(ans,s[i]-i-l);
	}
	cout<<fixed<<setprecision(4)<<ans<<endl;
	return 0;
}

Compilation message

sure.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
sure.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -