답안 #249904

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
249904 2020-07-16T11:32:32 Z receed Gap (APIO16_gap) C++14
100 / 100
71 ms 1172 KB
#include "gap.h"
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

ll findGap(int t, int n) {
    ll l, r, x, y, ls;
    MinMax(0, 1'000000'000000'000000, &l, &r);
    if (t == 2) {
        ll ans = (r - l + n - 2) / (n - 1), d = ans;
        ls = l;
        for (int i = 0; i < n - 1; i++) {
            ll lp = l + 1 + d * i, rp = l + d * (i + 1);
            if (lp >= r)
                break;
            rp = min(rp, r);
            MinMax(lp, rp, &x, &y);
            if (y != -1) {
                ans = max(ans, x - ls);
                ls = y;
            }
        }
        ans = max(ans, r - ls);
        return ans;
    }
    else {
        ll ans = 0;
        n -= 2;
        while (n > 0 && r - l > 1) {
            MinMax(l + 1, r - 1, &x, &y);
            if (x == -1) {
                ans = max(ans, r - l);
                break;
            }
            ans = max(ans, x - l);
            ans = max(ans, r - y);
            l = x;
            r = y;
            n -= 2;
        }
        ans = max(ans, r - l);
        return ans;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 12 ms 512 KB Output is correct
17 Correct 12 ms 512 KB Output is correct
18 Correct 12 ms 512 KB Output is correct
19 Correct 12 ms 512 KB Output is correct
20 Correct 10 ms 512 KB Output is correct
21 Correct 50 ms 1144 KB Output is correct
22 Correct 49 ms 1144 KB Output is correct
23 Correct 49 ms 1144 KB Output is correct
24 Correct 50 ms 1144 KB Output is correct
25 Correct 41 ms 1152 KB Output is correct
26 Correct 49 ms 1172 KB Output is correct
27 Correct 59 ms 1144 KB Output is correct
28 Correct 51 ms 1144 KB Output is correct
29 Correct 49 ms 1144 KB Output is correct
30 Correct 37 ms 1152 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 16 ms 512 KB Output is correct
17 Correct 16 ms 512 KB Output is correct
18 Correct 16 ms 512 KB Output is correct
19 Correct 15 ms 512 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 65 ms 1148 KB Output is correct
22 Correct 66 ms 1144 KB Output is correct
23 Correct 65 ms 1144 KB Output is correct
24 Correct 66 ms 1132 KB Output is correct
25 Correct 59 ms 1144 KB Output is correct
26 Correct 65 ms 1144 KB Output is correct
27 Correct 69 ms 1148 KB Output is correct
28 Correct 71 ms 1168 KB Output is correct
29 Correct 66 ms 1144 KB Output is correct
30 Correct 35 ms 1144 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct