답안 #70641

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70641 2018-08-23T08:01:04 Z polyfish Gap (APIO16_gap) C++14
86.3068 / 100
131 ms 9232 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 = 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 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Correct 2 ms 636 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 3 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 3 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 3 ms 692 KB Output is correct
12 Correct 3 ms 692 KB Output is correct
13 Correct 4 ms 692 KB Output is correct
14 Correct 3 ms 692 KB Output is correct
15 Correct 3 ms 692 KB Output is correct
16 Correct 17 ms 1788 KB Output is correct
17 Correct 19 ms 1788 KB Output is correct
18 Correct 17 ms 1788 KB Output is correct
19 Correct 18 ms 1880 KB Output is correct
20 Correct 13 ms 1880 KB Output is correct
21 Correct 69 ms 5328 KB Output is correct
22 Correct 63 ms 5328 KB Output is correct
23 Correct 63 ms 5408 KB Output is correct
24 Correct 71 ms 5408 KB Output is correct
25 Correct 54 ms 5408 KB Output is correct
26 Correct 70 ms 5408 KB Output is correct
27 Correct 96 ms 5408 KB Output is correct
28 Correct 72 ms 5408 KB Output is correct
29 Correct 65 ms 5408 KB Output is correct
30 Correct 49 ms 5408 KB Output is correct
31 Correct 2 ms 5408 KB Output is correct
32 Correct 3 ms 5408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5408 KB Output is correct
2 Partially correct 2 ms 5408 KB Partially correct
3 Partially correct 2 ms 5408 KB Partially correct
4 Partially correct 2 ms 5408 KB Partially correct
5 Correct 2 ms 5408 KB Output is correct
6 Partially correct 2 ms 5408 KB Partially correct
7 Partially correct 3 ms 5408 KB Partially correct
8 Partially correct 2 ms 5408 KB Partially correct
9 Partially correct 3 ms 5408 KB Partially correct
10 Partially correct 4 ms 5408 KB Partially correct
11 Partially correct 4 ms 5408 KB Partially correct
12 Partially correct 3 ms 5408 KB Partially correct
13 Partially correct 4 ms 5408 KB Partially correct
14 Partially correct 3 ms 5408 KB Partially correct
15 Correct 5 ms 5408 KB Output is correct
16 Partially correct 25 ms 5408 KB Partially correct
17 Partially correct 28 ms 5408 KB Partially correct
18 Partially correct 26 ms 5408 KB Partially correct
19 Partially correct 25 ms 5408 KB Partially correct
20 Correct 13 ms 5408 KB Output is correct
21 Partially correct 131 ms 9216 KB Partially correct
22 Partially correct 111 ms 9216 KB Partially correct
23 Partially correct 97 ms 9216 KB Partially correct
24 Partially correct 124 ms 9216 KB Partially correct
25 Correct 80 ms 9216 KB Output is correct
26 Partially correct 104 ms 9216 KB Partially correct
27 Partially correct 107 ms 9216 KB Partially correct
28 Partially correct 106 ms 9216 KB Partially correct
29 Partially correct 108 ms 9232 KB Partially correct
30 Correct 48 ms 9232 KB Output is correct
31 Partially correct 2 ms 9232 KB Partially correct
32 Partially correct 2 ms 9232 KB Partially correct