This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define llll std::pair<ll , ll>
#define pb push_back
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
#define debug std::cout << "!!ALERT ALERT!!" << std::endl;
const ll limit = 1e18+7;
const ll sus = 1e6;
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll a , ll b){
return (rng() % (b-a+1)) + a;
}
/*global variables*/
ll n;
std::vector<std::pair<ld,ld>> ar;
/**/
/*functions*/
/**/
void solve(){
std::cin >> n;
ar.resize(n);
std::vector<ld> fa , fb , pfa , pfb;
for(ll i=0;n>i;i++){
std::cin >> ar[i].fi >> ar[i].sec;
if(ar[i].fi >= 1.0){
fa.pb(ar[i].fi);
}
if(ar[i].sec >= 1.0){
fb.pb(ar[i].sec);
}
}
if(fa.size() == 0 || fb.size() == 0){
std::cout << 0 << "\n";
return;
}
ld ans = 0;
//std::cout << fa.size() << std::endl;
std::sort(fa.begin() , fa.end());
std::sort(fb.begin() , fb.end());
std::reverse(all(fa));
std::reverse(all(fb));
pfa.resize(fa.size());
pfb.resize(fb.size());
pfa[0] = fa[0] - 1;
pfb[0] = fb[0] - 1;
for(ll i = 1;fa.size() > i;i++){
pfa[i] += fa[i] + pfa[i-1] -1;
}
for(ll i = 1;fb.size() > i;i++){
pfb[i] += fb[i] + pfb[i-1] -1;
}
ld ba = 0;
for(ll i = 0;fa.size()>i;i++){
ba += fa[i] - 1;
ll l = 0 , r = (ll)fb.size() - 1;
while(r > l){
ll md = (l + r + 1)/2;
if(pfb[md] - (i+1) > ba - (md+1)){
r = md-1;
}
else{
l = md;
}
}
if(pfb[l] - (i+1) > ba - (l+1)){
continue;
}
ans = std::max(ans , pfb[l] - (i+1));
}
ba = 0;
for(ll i = 0;fb.size()>i;i++){
ba += fb[i] - 1;
ll l = 0 , r = (ll)fa.size() - 1;
while(r > l){
ll md = (l + r + 1)/2;
if(pfa[md] - (i+1) > ba - (md+1)){
r = md-1;
}
else{
l = md;
}
}
if(pfa[l] - (i+1) > ba - (l+1)){
continue;
}
ans = std::max(ans , pfa[l] - (i+1));
}
std::cout << std::setprecision(4) << std::fixed;
std::cout << ans;
return;/**/
}
int main(){
std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
/*#ifndef ONLINE_JUDGE
freopen("in.txt" , "r" , stdin);
freopen("out.txt" , "w" , stdout);
#endif*/
ll t = 1;
//std::cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
sure.cpp:5:78: warning: "/*" within comment [-Wcomment]
5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
|
sure.cpp: In function 'void solve()':
sure.cpp:54:28: warning: comparison of integer expressions of different signedness: 'std::vector<long double>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
54 | for(ll i = 1;fa.size() > i;i++){
| ~~~~~~~~~~^~~
sure.cpp:57:28: warning: comparison of integer expressions of different signedness: 'std::vector<long double>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
57 | for(ll i = 1;fb.size() > i;i++){
| ~~~~~~~~~~^~~
sure.cpp:61:27: warning: comparison of integer expressions of different signedness: 'std::vector<long double>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
61 | for(ll i = 0;fa.size()>i;i++){
| ~~~~~~~~~^~
sure.cpp:79:27: warning: comparison of integer expressions of different signedness: 'std::vector<long double>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
79 | for(ll i = 0;fb.size()>i;i++){
| ~~~~~~~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |