답안 #229431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229431 2020-05-04T13:06:30 Z bharat2002 Sure Bet (CEOI17_sure) C++14
0 / 100
5 ms 384 KB
/*input
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second 
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl 
//Trace prints the name of the variable and the value.
double a[N], b[N];int n;
bool sf(double f, double s)
{
	return f>s;
}
bool p(double x)
{
//	cout<<x<<": ";
	for(int i=1;i<=n;i++)
	{
		double ti=i+0.0;
		int temp=(a[i]-ti-x);ti+=temp;
//		cout<<i<<" "<<temp<<endl;
		if(temp>0&&b[temp]-ti>=x) return 1;
	}
	return 0;
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	double low=0.000, high=3e8;
	sort(a+1, a+n+1, sf);sort(b+1, b+n+1, sf);
	for(int i=2;i<=n;i++) {a[i]+=a[i-1];b[i]+=b[i-1];}
	while(high-low>1e-8)
	{
		double mid=(low+high)/2;
		if(p(mid)) low=mid;
		else high=mid;
	}
	cout<<fixed<<setprecision(4)<<low;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -