답안 #237811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
237811 2020-06-08T22:05:50 Z eohomegrownapps Sure Bet (CEOI17_sure) C++14
100 / 100
140 ms 11512 KB
#include <bits/stdc++.h>
using namespace std;

typedef long double ld;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	vector<ld> vals1(n);
	vector<ld> vals2(n);
	vector<ld> pref1(n+1);
	vector<ld> pref2(n+1);
	vector<ld> prefind1(n+1);
	vector<ld> prefind2(n+1);
	for (int i = 0; i<n; i++){
		cin>>vals1[i]>>vals2[i];
	}
	sort(vals1.rbegin(),vals1.rend());
	sort(vals2.rbegin(),vals2.rend());
	for (int i = 1; i<=n; i++){
		pref1[i]=pref1[i-1]+vals1[i-1]-1;
		prefind1[i]=pref1[i]+i;
		pref2[i]=pref2[i-1]+vals2[i-1]-1;
		prefind2[i]=pref2[i]+i;
	}
	ld maxval = 0;
	for (int i = 0; i<=n; i++){
		//smallest x such that prefind1[i]<prefind2[x]
		//cout<<"x "<<i<<'\n';
		int lb = lower_bound(prefind2.begin(),prefind2.end(),prefind1[i])-prefind2.begin();
		//cout<<lb<<'\n';
		if (lb!=n+1){maxval=max(maxval,pref1[i]-lb);}
		int ub = lb-1;
		//cout<<ub<<'\n';
		if (ub!=-1){maxval=max(maxval,pref2[ub]-i);}
	}
	cout<<fixed<<setprecision(4)<<maxval<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 512 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 6 ms 512 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 6 ms 512 KB Output is correct
17 Correct 125 ms 11072 KB Output is correct
18 Correct 128 ms 11128 KB Output is correct
19 Correct 131 ms 11128 KB Output is correct
20 Correct 129 ms 11256 KB Output is correct
21 Correct 140 ms 11512 KB Output is correct
22 Correct 129 ms 11128 KB Output is correct
23 Correct 129 ms 11256 KB Output is correct
24 Correct 130 ms 11260 KB Output is correct
25 Correct 127 ms 11256 KB Output is correct
26 Correct 139 ms 11512 KB Output is correct