#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int n;
vector<long double>psa,psb,alla,allb;
void vorod(){
cin>>n;
alla.resize(n);
allb.resize(n);
for(int i=0;i<n;i++){
cin>>alla[i]>>allb[i];
}
}
void pre(){
sort(allb.rbegin(),allb.rend());
sort(alla.rbegin(),alla.rend());
psa.resize(n);
psb.resize(n);
psa[0]=alla[0];
psb[0]=allb[0];
for(int i=1;i<n;i++){
psa[i]=psa[i-1]+alla[i];
psb[i]=psb[i-1]+allb[i];
}
}
void solve(){
long double res=0;
for(int i=1;i<=n*2;i++){
long double low=0,high=1000*i+1,mid;
for(int j=0;j<100;j++){
mid=(high+low)/2;
mid+=i;
int pa=lower_bound(psa.begin(),psa.end(),mid)-psa.begin();
int pb=lower_bound(psb.begin(),psb.end(),mid)-psb.begin();
if(pa==(int)psa.size()||pb==(int)psb.size()){
high=mid-i;
continue;
}
if(pa+pb+2<=i){
low=mid-i;
continue;
}
high=mid-i;
}
res=max(res,low);
}
cout<<setprecision(4)<<fixed<<res<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vorod();
pre();
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
13 ms |
544 KB |
Output is correct |
13 |
Correct |
14 ms |
348 KB |
Output is correct |
14 |
Correct |
14 ms |
348 KB |
Output is correct |
15 |
Correct |
14 ms |
540 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
13 ms |
544 KB |
Output is correct |
13 |
Correct |
14 ms |
348 KB |
Output is correct |
14 |
Correct |
14 ms |
348 KB |
Output is correct |
15 |
Correct |
14 ms |
540 KB |
Output is correct |
16 |
Correct |
16 ms |
348 KB |
Output is correct |
17 |
Correct |
1933 ms |
8096 KB |
Output is correct |
18 |
Correct |
1917 ms |
8096 KB |
Output is correct |
19 |
Correct |
1937 ms |
8092 KB |
Output is correct |
20 |
Correct |
1906 ms |
8020 KB |
Output is correct |
21 |
Correct |
1921 ms |
8464 KB |
Output is correct |
22 |
Correct |
1869 ms |
8016 KB |
Output is correct |
23 |
Correct |
1972 ms |
8016 KB |
Output is correct |
24 |
Correct |
1989 ms |
8272 KB |
Output is correct |
25 |
Correct |
1885 ms |
8020 KB |
Output is correct |
26 |
Correct |
1985 ms |
8464 KB |
Output is correct |