답안 #534558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534558 2022-03-08T09:38:59 Z pokmui9909 Gap (APIO16_gap) C++17
100 / 100
64 ms 3276 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define x first
#define y second

pair<ll, ll> ask(ll s, ll e){
    pair<ll, ll> p;
    MinMax(s, e, &p.x, &p.y);
    return p;
}

long long findGap(int T, int N){
    vector<ll> A;
    if(T == 1){
        ll L = 0, R = 2e18;
        while(N >= 1){
            pair<ll, ll> r = ask(L, R);
            A.push_back(r.x);
            A.push_back(r.y);
            L = r.x + 1, R = r.y - 1;
            N -= 2;
        }
    } else {
        pair<ll, ll> r = ask(0, 1e18 + 5);
        ll md = (r.y - r.x) / (N - 1) + 1;
        for(ll i = r.x; i <= r.y; i += md + 1){
            pair<ll, ll> p = ask(i, i + md);
            A.push_back(p.x);
            A.push_back(p.y);
        }
    }
    sort(A.begin(), A.end());
    ll ans = 0;
    for(int i = 0; i < A.size() - 1; i++){
        ans = max(ans, A[i + 1] - A[i]);
    }
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0; i < A.size() - 1; i++){
      |                    ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 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 1 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 11 ms 840 KB Output is correct
17 Correct 12 ms 800 KB Output is correct
18 Correct 10 ms 800 KB Output is correct
19 Correct 10 ms 840 KB Output is correct
20 Correct 9 ms 892 KB Output is correct
21 Correct 44 ms 2232 KB Output is correct
22 Correct 49 ms 2196 KB Output is correct
23 Correct 43 ms 2152 KB Output is correct
24 Correct 44 ms 2248 KB Output is correct
25 Correct 37 ms 2200 KB Output is correct
26 Correct 44 ms 2172 KB Output is correct
27 Correct 43 ms 2220 KB Output is correct
28 Correct 42 ms 2128 KB Output is correct
29 Correct 45 ms 2232 KB Output is correct
30 Correct 39 ms 2240 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 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 18 ms 1076 KB Output is correct
17 Correct 16 ms 1052 KB Output is correct
18 Correct 15 ms 1112 KB Output is correct
19 Correct 15 ms 1092 KB Output is correct
20 Correct 8 ms 1092 KB Output is correct
21 Correct 60 ms 3220 KB Output is correct
22 Correct 61 ms 3232 KB Output is correct
23 Correct 61 ms 3252 KB Output is correct
24 Correct 64 ms 3240 KB Output is correct
25 Correct 52 ms 3208 KB Output is correct
26 Correct 61 ms 3200 KB Output is correct
27 Correct 60 ms 3232 KB Output is correct
28 Correct 58 ms 3276 KB Output is correct
29 Correct 62 ms 3208 KB Output is correct
30 Correct 33 ms 3204 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct