답안 #865463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865463 2023-10-24T08:50:07 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#define ll long long
#define Sayan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define Int(a,x) a+1 , a+1+x
#define sz() size()
#define F first
#define S second
#define pb push_back
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define pii pair<ll,ll>
using namespace std ;

const ll N = 2e5+5;
const ll INF = 1e18;
const ll mod = 1e9+7;

/*
ll binpow(ll a , ll b){
    if(b == 0) return 1;
    if(b%2) return binpow(a , b-1) * a % mod;
    ll c = binpow(a , b/2) % mod;
    return c*c%mod;
}
*/
double l[N],r[N];
void solve(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>l[i]>>r[i];
	}
	sort(l+1,l+1+n);
	reverse(l+1,l+1+n);
	sort(r+1,r+1+n);
	reverse(r+1,r+1+n);
	if(l[1]>=r[1]){
		double sum=0,cnt=0;
		for(ll i=1;i<=n;i++){
			if(sum+r[i]>l[1])break;
			sum+=r[i];
			cnt++;
		}
		cout<<fixed<<setprecision(4)<<min(sum-(cnt+1),l[1]-(cnt+1))<<"\n";
	}
	else {
		double sum=0,cnt=0;
		for(ll i=1;i<=n;i++){
			if(sum+l[i]>r[1])break;
			sum+=l[i];
			cnt++;
		}
		cout<<fixed<<setprecision(4)<<min(sum-(cnt+1),r[1]-(cnt+1))<<"\n";
	}
//	printf("%.4lf",(double)mx);
}
signed main () {
	Sayan;
	ll t=1;
	//cin>>t;
	while(t--)solve();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -