답안 #617163

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
617163 2022-08-01T09:14:48 Z cfalas Sure Bet (CEOI17_sure) C++17
100 / 100
175 ms 4368 KB
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second

#define ll long long
#define FORi(i,a,b) for(ll i=a;i<(ll)b;i++)
#define FOR(i,n) FORi(i,0,n)
#define FOA(v,a) for(auto v : a)
#define MID ((l+r)/2)

int n;
vector<double> a, b;

int main(){
	cin>>n;
	a.resize(n);
	b.resize(n);
	FOR(i,n) cin>>a[i]>>b[i];
	sort(a.begin(), a.end(), [](double a, double b){return a>b;});
	sort(b.begin(), b.end(), [](double a, double b){return a>b;});

	double ans=0;
	double sa=0;

	double sb[n];
	sb[0] = b[0];
	FORi(i,1,n) sb[i] = sb[i-1] + b[i];
	FOR(i,n){
		sa+=a[i];
		int nxt = lower_bound(sb, sb+n, sa)-sb;
		if(nxt!=n+1)
			ans = max(ans, min(sb[nxt]-i-1-nxt-1, sa-nxt-1-i-1));
		if(nxt!=0){
			nxt--;
			ans = max(ans, min(sb[nxt]-i-1-nxt-1, sa-nxt-1-i-1));
		}
	}
	cout<<fixed<<setprecision(4)<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 296 KB Output is correct
14 Correct 3 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 296 KB Output is correct
14 Correct 3 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 150 ms 3992 KB Output is correct
18 Correct 149 ms 4000 KB Output is correct
19 Correct 137 ms 3996 KB Output is correct
20 Correct 171 ms 4008 KB Output is correct
21 Correct 171 ms 4272 KB Output is correct
22 Correct 142 ms 4016 KB Output is correct
23 Correct 134 ms 3888 KB Output is correct
24 Correct 146 ms 4020 KB Output is correct
25 Correct 133 ms 3996 KB Output is correct
26 Correct 175 ms 4368 KB Output is correct