답안 #70634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70634 2018-08-23T07:56:25 Z polyfish Gap (APIO16_gap) C++14
86.3068 / 100
106 ms 9324 KB
//I love armpit fetish

#include <bits/stdc++.h>
#include "gap.h"
using namespace std;

#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const long long INF = 1e18;
const int MAX_N = 100002;

int n;
long long a[MAX_N];

void Find(long long l, long long r, long long &u, long long &v) {
    long long *mn = new long long;
    long long *mx = new long long;
    MinMax(l, r, mn, mx);
    u = *mn;
    v = *mx;
}

long long solve_subtask_1() {
    int l = 1, r = n;
    long long s = 1, t = INF;
    while (l<=r) {
        long long mn, mx;
        Find(s, t, mn, mx);
        a[l] = mn;
        a[r] = mx;
        s = mn + 1;
        t = mx - 1;
        ++l;
        --r;
    }
    long long res = 0;
    for (int i=2; i<=n; ++i)
        res = max(res, a[i] - a[i-1]);
    return res;
}

long long solve_subtask_2() {
    long long l, r;
    Find(1, INF, l, r);
    long long B = (r - l) / (n - 1) + ((r - l) % (n - 1) != 0);
    long long cur = l + 1;
    long long res = (r - l) / B;
    long long _prev = l;
    while (cur<=r) {
        long long mn, mx;
        Find(cur, cur+B, mn, mx);
        if (mn==-1) {
            cur += B + 1;
        }
        else {
            res = max(res, mn - _prev);
            cur = mx + 1;
            _prev = mx;
        }
    }
    return res;
}

long long findGap(int testID, int N) {
    n = N;
    if (testID==1)
        return solve_subtask_1();
    else
        return solve_subtask_2();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 2 ms 496 KB Output is correct
4 Correct 2 ms 496 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 2 ms 588 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 4 ms 588 KB Output is correct
12 Correct 4 ms 588 KB Output is correct
13 Correct 4 ms 632 KB Output is correct
14 Correct 4 ms 684 KB Output is correct
15 Correct 3 ms 684 KB Output is correct
16 Correct 16 ms 1748 KB Output is correct
17 Correct 17 ms 1748 KB Output is correct
18 Correct 17 ms 1748 KB Output is correct
19 Correct 17 ms 1748 KB Output is correct
20 Correct 13 ms 1748 KB Output is correct
21 Correct 74 ms 5236 KB Output is correct
22 Correct 73 ms 5332 KB Output is correct
23 Correct 65 ms 5332 KB Output is correct
24 Correct 66 ms 5424 KB Output is correct
25 Correct 52 ms 5424 KB Output is correct
26 Correct 79 ms 5424 KB Output is correct
27 Correct 62 ms 5424 KB Output is correct
28 Correct 63 ms 5424 KB Output is correct
29 Correct 59 ms 5424 KB Output is correct
30 Correct 47 ms 5424 KB Output is correct
31 Correct 3 ms 5424 KB Output is correct
32 Correct 4 ms 5424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5424 KB Output is correct
2 Partially correct 2 ms 5424 KB Partially correct
3 Partially correct 3 ms 5424 KB Partially correct
4 Partially correct 3 ms 5424 KB Partially correct
5 Correct 2 ms 5424 KB Output is correct
6 Partially correct 3 ms 5424 KB Partially correct
7 Partially correct 3 ms 5424 KB Partially correct
8 Partially correct 2 ms 5424 KB Partially correct
9 Partially correct 2 ms 5424 KB Partially correct
10 Partially correct 2 ms 5424 KB Partially correct
11 Partially correct 4 ms 5424 KB Partially correct
12 Partially correct 3 ms 5424 KB Partially correct
13 Partially correct 4 ms 5424 KB Partially correct
14 Partially correct 4 ms 5424 KB Partially correct
15 Correct 3 ms 5424 KB Output is correct
16 Partially correct 29 ms 5424 KB Partially correct
17 Partially correct 25 ms 5424 KB Partially correct
18 Partially correct 26 ms 5424 KB Partially correct
19 Partially correct 27 ms 5424 KB Partially correct
20 Correct 18 ms 5424 KB Output is correct
21 Partially correct 94 ms 9196 KB Partially correct
22 Partially correct 98 ms 9196 KB Partially correct
23 Partially correct 93 ms 9196 KB Partially correct
24 Partially correct 106 ms 9196 KB Partially correct
25 Correct 78 ms 9196 KB Output is correct
26 Partially correct 102 ms 9196 KB Partially correct
27 Partially correct 95 ms 9324 KB Partially correct
28 Partially correct 92 ms 9324 KB Partially correct
29 Partially correct 96 ms 9324 KB Partially correct
30 Correct 57 ms 9324 KB Output is correct
31 Partially correct 2 ms 9324 KB Partially correct
32 Partially correct 3 ms 9324 KB Partially correct