답안 #498401

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498401 2021-12-25T06:25:50 Z AQ0212 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 204 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cstring>

// #pragma GCC optimize("inline")
// #pragma GCC optimize("-fgcse,-fgcse-lm")
// #pragma GCC optimize("-ftree-pre,-ftree-vrp")
// #pragma GCC optimize("-ffast-math")
// #pragma GCC optimize("-fipa-sra")
// #pragma GCC optimize("-fpeephole2")
// #pragma GCC optimize("-fsched-spec")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#define ll long long int
#define pb push_back
#define pll pair < ll , ll >
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;

ll inf2 = 3e18;

double a[ 100111 ], b[ 100111 ], sum1, sum2, sit1, sit2, cnt, grnt;
pair < double , double > c[ 100111 ];
vector < pll > unused, overused;

int main(){
    ll n;

    cin >> n;

    for(int i = 1; i <= n; i ++){
        cin >> a[ i ] >> b[ i ];

        // c[ i ].fi = a[ i ];
        // c[ i ].se = b[ i ];
    }

    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);

    sum1 += a[ n ];
    sum2 += b[ n ];
    cnt += 2.0;
    sit1 = sum1 - cnt;
    sit2 = sum2 - cnt;
    grnt = min(sit1, sit2);

    for(int i = n - 1; i >= 1; i --){
        if(a[ i ] + sum1 - cnt - 1.0 > grnt && sum2 - cnt - 1.0 > grnt){
            sum1 += a[ i ];
            cnt ++;
            sit1 = sum1 - cnt;
            sit2 = sum1 - cnt;
            grnt = min(sit1, sit2);
        }
        if(b[ i ] + sum2 - cnt - 1.0 > grnt && sum1 - cnt - 1.0 > grnt){
            sum2 += b[ i ];
            cnt ++;
            sit1 = sum1 - cnt;
            sit2 = sum2 - cnt;
            grnt = min(sit1, sit2);
        }
    }

    printf("%.4lf", grnt);
}

/*

4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5

*/

# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -