답안 #576211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576211 2022-06-12T13:58:34 Z Pietra Sure Bet (CEOI17_sure) C++14
60 / 100
92 ms 6860 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 >= 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 ; double mn = p_x[i] ; 
    	while(ini <= fim){
    		mid = (ini + fim)>>1 ;
    		if(abs((p_x[i] - mid - i)-(p_y[mid] - mid - i)) <= mn){
    			mn = abs((p_x[i] - mid - i)-(p_y[mid] - mid - i)) ; 
    			best = mid ; 
    		} 
    		if(p_x[i] - mid - i <= p_y[mid] - mid - i) 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

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]) ;
      |                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 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 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 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 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 80 ms 3540 KB Output is correct
18 Correct 72 ms 3512 KB Output is correct
19 Correct 74 ms 3548 KB Output is correct
20 Correct 92 ms 3488 KB Output is correct
21 Correct 75 ms 3528 KB Output is correct
22 Correct 73 ms 3484 KB Output is correct
23 Runtime error 82 ms 6860 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -