답안 #578445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
578445 2022-06-16T23:36:05 Z Pietra Sure Bet (CEOI17_sure) C++14
100 / 100
171 ms 3452 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(){
 
    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 ; 
 
    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])-(p_y[mid])) <= mn){
                mn = abs((p_x[i])-(p_y[mid])) ; 
                best = mid ; 
            } 
            if(p_x[i] <= p_y[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" ; 
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 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 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 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 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 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 146 ms 3324 KB Output is correct
18 Correct 135 ms 3404 KB Output is correct
19 Correct 138 ms 3388 KB Output is correct
20 Correct 162 ms 3296 KB Output is correct
21 Correct 163 ms 3452 KB Output is correct
22 Correct 134 ms 3388 KB Output is correct
23 Correct 139 ms 3316 KB Output is correct
24 Correct 139 ms 3412 KB Output is correct
25 Correct 138 ms 3312 KB Output is correct
26 Correct 171 ms 3424 KB Output is correct