답안 #40095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40095 2018-01-26T17:10:52 Z toonewbie Sure Bet (CEOI17_sure) C++14
0 / 100
0 ms 5304 KB
/*
ID: usaco.t3
TASK: test
LANG: C++14
*/

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define pii pair<intt,intt>
#define vi vector<intt>
#define vii vector<pii>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

#define wtfis(x) cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl

const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
const intt INFLL = 9LL * 1000000000 * 1000000000;
/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

int n;
double arr[maxx], brr[maxx];
double pa[maxx], pb[maxx];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i] >> brr[i];
    }
    sort (arr + 1, arr + n + 1); reverse (arr + 1, arr + n + 1);
    sort (brr + 1, brr + n + 1); reverse (brr + 1, brr + n + 1);
    for (int i = 1; i <= n; i++) {
        pa[i] = pa[i - 1] + arr[i];
        pb[i] = pb[i - 1] + brr[i];
    }
    double res = 0;
    for (int i = 0; i <= n; i++) { /// select first i from arr
        double cur_res = 0;
        int j; /// j is value such min(pa[i] - (i + j), pb[j] - (i + j)) is maximized
        for (j = 0; j <= n; j++) { /// checking brute-force solution
            cur_res = max (cur_res, min(pa[i] - (i + j), pb[j] - (i + j)));
        }
        res = max (res, cur_res);
    }
    cout << fixed << setprecision(5) << res << endl;
    return 0;
}

Compilation message

sure.cpp:7:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 ^
sure.cpp: In function 'long long int is_prime(long long int)':
sure.cpp:74:25: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
                         ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 5304 KB Output isn't correct
2 Halted 0 ms 0 KB -