답안 #400625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400625 2021-05-08T12:12:07 Z Falcon Gap (APIO16_gap) C++17
100 / 100
69 ms 1936 KB
#include "gap.h"
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>

long long findGap(int T, int N) {
    if(T == 1) {
        std::vector<long long> a; a.reserve(N);
        long long s{0}, e{(long long)1e18}; 
        while(int(a.size()) < N) {
            MinMax(s, e, &s, &e);
            assert(s != -1);
            a.push_back(s); a.push_back(e);
            ++s, --e;
        }
        std::sort(a.begin(), a.end());
        long long ans{};
        for(int i{}; i < int(a.size()) - 1; ++i)
            ans = std::max(ans, a[i + 1] - a[i]);
        return ans;
    }

    
    long long a1{}, aN{};
    MinMax(0, (long long)1e18, &a1, &aN);

    long long d = (aN - a1 + N - 2) / (N - 1), ans = d;
    for(long long i = a1, p = a1; i <= aN; i += d + 1) {
        long long s{}, e{};
        MinMax(i, std::min(i + d, aN), &s, &e);
        if(~s)
            ans = std::max(ans, s - p), p = e;
    }
	return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 13 ms 708 KB Output is correct
17 Correct 13 ms 584 KB Output is correct
18 Correct 13 ms 712 KB Output is correct
19 Correct 13 ms 712 KB Output is correct
20 Correct 10 ms 584 KB Output is correct
21 Correct 50 ms 1856 KB Output is correct
22 Correct 49 ms 1776 KB Output is correct
23 Correct 58 ms 1936 KB Output is correct
24 Correct 51 ms 1856 KB Output is correct
25 Correct 45 ms 1824 KB Output is correct
26 Correct 50 ms 1832 KB Output is correct
27 Correct 52 ms 1820 KB Output is correct
28 Correct 50 ms 1840 KB Output is correct
29 Correct 50 ms 1812 KB Output is correct
30 Correct 40 ms 1812 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 280 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 2 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 15 ms 456 KB Output is correct
17 Correct 15 ms 540 KB Output is correct
18 Correct 16 ms 452 KB Output is correct
19 Correct 15 ms 456 KB Output is correct
20 Correct 7 ms 456 KB Output is correct
21 Correct 68 ms 1016 KB Output is correct
22 Correct 62 ms 960 KB Output is correct
23 Correct 62 ms 1172 KB Output is correct
24 Correct 69 ms 1220 KB Output is correct
25 Correct 57 ms 1028 KB Output is correct
26 Correct 62 ms 1072 KB Output is correct
27 Correct 61 ms 956 KB Output is correct
28 Correct 64 ms 1000 KB Output is correct
29 Correct 62 ms 1068 KB Output is correct
30 Correct 33 ms 1096 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct