This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 5 ;
int n ;
double x[maxn], y[maxn], p_x[maxn], p_y[maxn] ;
bool cmp(double a, double b){ return a >= b ; }
int main(){
scanf("%d",&n) ;
for(int i = 1 ; i <= n ; i++) scanf("%lf%lf", &x[i],&y[i]) ;
sort(x + 1, x + 1 + n, cmp) ; sort(y + 1, y + 1 + n, cmp) ;
for(int i = 1 ; i <= n ; i++) p_x[i] = p_x[i-1] + x[i], p_y[i] = p_y[i-1] + y[i] ;
double ans = 0 ;
for(int i = 1 ; i <= n ; i++){
int ini = 1, fim = n, mid, best = 0 ;
while(ini <= fim){
mid = (ini + fim)>>1 ;
if(p_x[i] - mid - i <= p_y[mid] - mid - i) best = mid, fim = mid - 1 ;
else ini = mid + 1 ;
}
ans = max(ans, min(p_x[i] - (double)best - (double)i, p_y[best] - (double)i - (double)best)) ;
}
printf("%.4lf\n", ans) ;
}
Compilation message (stderr)
sure.cpp: In function 'int main()':
sure.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d",&n) ;
| ~~~~~^~~~~~~~~
sure.cpp:15:37: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | for(int i = 1 ; i <= n ; i++) scanf("%lf%lf", &x[i],&y[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... |