답안 #229444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229444 2020-05-04T13:58:45 Z bharat2002 Sure Bet (CEOI17_sure) C++14
0 / 100
5 ms 384 KB
#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.
long double a[N], b[N];int n;
bool sf(long double f, long double s)
{
	return f>s;
}
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];
	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];}
	int i=1, j=1;a[n+1]=b[n+1]=1000000000;
	long double ans=0.0;
	while(i<n&&j<n)
	{
		ans=max(ans, min(a[i], b[j]) - i - j);
		while(a[i]<=b[j]&&i<n)
		{
			i++;ans=max(ans, min(a[i], b[j]) - i - j);
		}
		while(b[j]<=a[i]&&j<n)
		{
			j++;ans=max(ans, min(a[i], b[j]) - i - j);
		}
	}
	cout<<fixed<<setprecision(4)<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -