Submission #578427

# Submission time Handle Problem Language Result Execution time Memory
578427 2022-06-16T19:02:59 Z Pietra Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 212 KB
#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*1.00 > b*1.00 ; }
 
int main(){
 
	cin >> n ; 
 
	for(int i = 1 ; i <= n ; i++) cin >> 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.00 ; 
 
    for(int i = 1 ; i <= n ; i++){
    	int ini = 1, fim = n, mid, best = 0 ; double mn = p_x[i] ; 
    	while(ini <= fim){
    		mid = (ini + fim)>>1 ;
    		// if(abs((p_x[i] - mid)-(p_y[mid])) <= mn){
    		// 	mn = abs((p_x[i])-(p_y[mid])) ; 
    		// 	best = mid ; 
    		// } 
    		if(p_x[i] - i <= p_y[mid] - mid) best = mid, fim = mid - 1 ; 
    		else ini = mid + 1 ; 
    	}
    	if(best) ans = max(ans, min(p_x[i] - (double)best - (double)i, p_y[best] - (double)i - (double)best)) ; 
    }

    cout << fixed << setprecision(4) << ans << "\n" ; 

}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:24:51: warning: unused variable 'mn' [-Wunused-variable]
   24 |      int ini = 1, fim = n, mid, best = 0 ; double mn = p_x[i] ;
      |                                                   ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -