답안 #556896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556896 2022-05-04T10:17:05 Z Sharky Gap (APIO16_gap) C++17
100 / 100
66 ms 2256 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std; 
#define pb push_back
const long long inf = 1e18;
long long findGap(int T, int N) {
    if (T == 1) {
        pair<long long, long long> range = {1, inf};
        long long cnt = 0, mn, mx; 
        vector<long long> a; 
        for (long long i = 0; i < (N + 1) / 2; i++) {
            MinMax(range.first, range.second, &mn, &mx);
            range = {mn + 1, mx - 1};
            a.pb(mn); a.pb(mx);
        }
        sort(a.begin(), a.begin() + N); 
        long long ans = 0;
        for (long long i = 1; i < N; i++) ans = max(ans, a[i] - a[i - 1]);
        return ans; 
    }
    long long L = 1, R = inf, mn, mx; 
    MinMax(L, R, &mn, &mx);
    long long hole = (mx - mn - 1 + (N - 1)) / (N - 1);
    long long MN, MX, i, ans = hole, lst = mn;
    for (i = mn; i + hole < mx; i += hole + 1) {
        MinMax(i, i + hole, &MN, &MX);
        if (MN != -1) ans = max(ans, MN - lst), lst = MX; 
    }
    MinMax(i, mx, &MN, &MX);
    if (MN != -1) ans = max(ans, MN - lst);
    return ans; 
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:19: warning: unused variable 'cnt' [-Wunused-variable]
    9 |         long long cnt = 0, mn, mx;
      |                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 236 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 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 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 11 ms 848 KB Output is correct
17 Correct 12 ms 904 KB Output is correct
18 Correct 16 ms 864 KB Output is correct
19 Correct 10 ms 904 KB Output is correct
20 Correct 10 ms 872 KB Output is correct
21 Correct 44 ms 2164 KB Output is correct
22 Correct 43 ms 2200 KB Output is correct
23 Correct 42 ms 2196 KB Output is correct
24 Correct 43 ms 2152 KB Output is correct
25 Correct 43 ms 2256 KB Output is correct
26 Correct 45 ms 2204 KB Output is correct
27 Correct 43 ms 2216 KB Output is correct
28 Correct 41 ms 2184 KB Output is correct
29 Correct 56 ms 2172 KB Output is correct
30 Correct 43 ms 2248 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 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 1 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 208 KB Output is correct
12 Correct 1 ms 208 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 13 ms 464 KB Output is correct
17 Correct 14 ms 464 KB Output is correct
18 Correct 12 ms 464 KB Output is correct
19 Correct 14 ms 432 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 54 ms 1188 KB Output is correct
22 Correct 53 ms 1048 KB Output is correct
23 Correct 66 ms 1064 KB Output is correct
24 Correct 52 ms 1076 KB Output is correct
25 Correct 47 ms 968 KB Output is correct
26 Correct 58 ms 1080 KB Output is correct
27 Correct 57 ms 1044 KB Output is correct
28 Correct 57 ms 1060 KB Output is correct
29 Correct 62 ms 1144 KB Output is correct
30 Correct 25 ms 1104 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct