답안 #256001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256001 2020-08-02T07:47:28 Z giorgikob Sure Bet (CEOI17_sure) C++14
100 / 100
192 ms 3576 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
//#define pb push_back
using namespace std;

const int N = 1e6;

int n;
double A[N], B[N];

int main(){

        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> A[i] >> B[i];
        }

        sort(A+1,A+1+n); reverse(A+1,A+1+n);
        sort(B+1,B+1+n); reverse(B+1,B+1+n);

        int pa = 2, pb = 2, cur = 2;
        double answer = 0, cnt = min(A[1],B[1]) - 2, suma = A[1], sumb = B[1];
        answer = max(answer,cnt);
        while(pa <= n || pb <= n){
                cur++;
                if(pa > n){
                        sumb += B[pb]; pb++;
                        cnt = min(suma, sumb) - cur;
                        continue;
                }

                if(pb > n){
                        suma += A[pa]; pa++;
                        cnt = min(suma, sumb) - cur;
                        continue;
                }

                if(suma < sumb){
                        suma += A[pa]; pa++;
                } else {
                        sumb += B[pb]; pb++;
                }

                cnt = min(suma, sumb) - cur;

                answer = max(answer, cnt);
        }

        printf("%0.4f", answer);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 169 ms 3320 KB Output is correct
18 Correct 175 ms 3192 KB Output is correct
19 Correct 173 ms 3192 KB Output is correct
20 Correct 170 ms 3320 KB Output is correct
21 Correct 190 ms 3576 KB Output is correct
22 Correct 172 ms 3320 KB Output is correct
23 Correct 168 ms 3320 KB Output is correct
24 Correct 167 ms 3320 KB Output is correct
25 Correct 169 ms 3192 KB Output is correct
26 Correct 192 ms 3576 KB Output is correct