답안 #315969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315969 2020-10-24T15:26:31 Z phathnv Gap (APIO16_gap) C++11
100 / 100
83 ms 3264 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;

typedef long long ll;

const ll INF = 1e18;

vector <ll> a;

ll findGap(int t, int n){
    if (t == 1){
        ll l = 0, r = INF;
        while (l <= r && n > 0){
            ll mn, mx;
            MinMax(l, r, &mn, &mx);
            if (mn == -1 && mx == -1)
                break;
            a.push_back(mn);
            n--;
            if (mx != mn){
                a.push_back(mx);
                n--;
            }
            l = mn + 1;
            r = mx - 1;
        }
        ll res = 0;
        sort(a.begin(), a.end());
        for(int i = 1; i < (int) a.size(); i++)
            res = max(res, a[i] - a[i - 1]);
        return res;
    } else {
        ll l, r, d, res;
        MinMax(0, INF, &l, &r);
        res = (r - l - n) / n;
        d = (r - l) / n;

        a.push_back(l);
        a.push_back(r);
        l++;
        r--;

        while (l <= r){
            ll mn, mx;
            MinMax(l, min(l + d, r), &mn, &mx);
            if (mn != -1 && mx != -1){
                a.push_back(mn);
                a.push_back(mx);
            }
            l += d + 1;
        }
        sort(a.begin(), a.end());
        for(int i = 1; i < (int) a.size(); i++)
            res = max(res, a[i] - a[i - 1]);
        return res;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 14 ms 896 KB Output is correct
17 Correct 16 ms 1024 KB Output is correct
18 Correct 14 ms 896 KB Output is correct
19 Correct 14 ms 896 KB Output is correct
20 Correct 10 ms 896 KB Output is correct
21 Correct 58 ms 2416 KB Output is correct
22 Correct 59 ms 2396 KB Output is correct
23 Correct 59 ms 2444 KB Output is correct
24 Correct 63 ms 2308 KB Output is correct
25 Correct 49 ms 2288 KB Output is correct
26 Correct 59 ms 2244 KB Output is correct
27 Correct 61 ms 2272 KB Output is correct
28 Correct 64 ms 2240 KB Output is correct
29 Correct 59 ms 2288 KB Output is correct
30 Correct 47 ms 2288 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 288 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 512 KB Output is correct
14 Correct 1 ms 416 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 18 ms 896 KB Output is correct
17 Correct 18 ms 896 KB Output is correct
18 Correct 17 ms 896 KB Output is correct
19 Correct 18 ms 896 KB Output is correct
20 Correct 8 ms 512 KB Output is correct
21 Correct 73 ms 2352 KB Output is correct
22 Correct 80 ms 2288 KB Output is correct
23 Correct 83 ms 2416 KB Output is correct
24 Correct 72 ms 2292 KB Output is correct
25 Correct 78 ms 3264 KB Output is correct
26 Correct 72 ms 2288 KB Output is correct
27 Correct 72 ms 2288 KB Output is correct
28 Correct 76 ms 2252 KB Output is correct
29 Correct 72 ms 2320 KB Output is correct
30 Correct 37 ms 1536 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct