Submission #576216

# Submission time Handle Problem Language Result Execution time Memory
576216 2022-06-12T14:08:25 Z Pietra Sure Bet (CEOI17_sure) C++14
60 / 100
77 ms 7072 KB
#include<bits/stdc++.h>
using namespace std ; 

int n ; 

bool cmp(double a, double b){ return a >= b ; }

int main(){

	scanf("%d",&n) ; 

	vector<double> x, y, p_x, p_y ; 

	for(int i = 1 ; i <= n ; i++) {
		double a, b ; scanf("%lf%lf", &a, &b) ; 
		x.push_back(a), y.push_back(b) ; 
		p_x.push_back(0), p_y.push_back(0) ; 
	}  

	sort(x.begin(), x.end(), cmp) ; sort(y.begin(), y.end(), cmp) ; 

	p_x[0] = x[0], p_y[0] = y[0] ; 

    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 = -1 ; double mn = p_x[i-1] ; 
    	while(ini <= fim){
    		mid = (ini + fim)>>1 ;
    		if(abs((p_x[i-1] - mid - i)-(p_y[mid-1] - mid - i)) <= mn){
    			mn = abs((p_x[i-1] - mid - i)-(p_y[mid-1] - mid - i)) ; 
    			best = mid ; 
    		} 
    		if(p_x[i-1] - mid - i <= p_y[mid-1] - mid - i) fim = mid - 1 ; 
    		else ini = mid + 1 ; 
    	}
    	if(best != -1) ans = max(ans, min(p_x[i-1] - (double)best - (double)i, p_y[best-1] - (double)i - (double)best)) ; 
    }

    printf("%.4lf\n", ans) ; 

}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d",&n) ;
      |  ~~~~~^~~~~~~~~
sure.cpp:15:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   double a, b ; scanf("%lf%lf", &a, &b) ;
      |                 ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 77 ms 3540 KB Output is correct
18 Runtime error 66 ms 7072 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -