답안 #585336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585336 2022-06-28T16:54:52 Z Do_you_copy Gap (APIO16_gap) C++14
100 / 100
65 ms 1860 KB
#include <bits/stdc++.h>
#include <gap.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

using ll = long long;
using pii = pair <int, int>;

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

const ll Mod = 1000000007;
const int maxN = 1e5 + 1;
const ll inf = LLONG_MAX;
int n;
ll a[maxN];

ll findGap(int T, int N){
    if (T & 1){
        ll mn, mx;
        MinMax(0, inf, &mn, &mx);
        a[1] = mn, a[N] = mx;
        for (int i = 2; i <= (N + 1) / 2; ++i){
            MinMax(mn + 1, mx - 1, &mn, &mx);
            a[i] = mn, a[N - i + 1] = mx;
        }
        ll ans = 0;
        for (int i = 2; i <= N; ++i){
            ans = max(ans, a[i] - a[i - 1]);
        }
        return ans;
    }
    else{
        ll mn, mx;
        MinMax(0, inf, &mn, &mx);
        ll ans = 0, last = LLONG_MAX;
        ll j = (mx - mn) / (N - 1);
        for (ll i = mn; i < mx; i += j + 1){
            ll x, y;
            MinMax(i, i + j, &x, &y);
            if (x == -1) continue;
            ans = max(ans, x - last);
            last = y;
        }
        if (N == 2) return mx - mn;
        return ans;
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 656 KB Output is correct
17 Correct 10 ms 632 KB Output is correct
18 Correct 10 ms 720 KB Output is correct
19 Correct 11 ms 620 KB Output is correct
20 Correct 8 ms 592 KB Output is correct
21 Correct 43 ms 1816 KB Output is correct
22 Correct 39 ms 1832 KB Output is correct
23 Correct 47 ms 1736 KB Output is correct
24 Correct 38 ms 1808 KB Output is correct
25 Correct 33 ms 1784 KB Output is correct
26 Correct 47 ms 1860 KB Output is correct
27 Correct 43 ms 1744 KB Output is correct
28 Correct 39 ms 1796 KB Output is correct
29 Correct 39 ms 1860 KB Output is correct
30 Correct 32 ms 1828 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 12 ms 524 KB Output is correct
17 Correct 14 ms 592 KB Output is correct
18 Correct 12 ms 464 KB Output is correct
19 Correct 13 ms 464 KB Output is correct
20 Correct 8 ms 484 KB Output is correct
21 Correct 63 ms 996 KB Output is correct
22 Correct 52 ms 1084 KB Output is correct
23 Correct 54 ms 1108 KB Output is correct
24 Correct 59 ms 1088 KB Output is correct
25 Correct 52 ms 968 KB Output is correct
26 Correct 65 ms 1104 KB Output is correct
27 Correct 56 ms 1064 KB Output is correct
28 Correct 53 ms 968 KB Output is correct
29 Correct 61 ms 1064 KB Output is correct
30 Correct 31 ms 976 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct