답안 #95786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
95786 2019-02-02T15:07:00 Z dantoh000 Gap (APIO16_gap) C++14
100 / 100
153 ms 3952 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;


long long findGap(int T, int n)
{
    if (T == 1){
        long long a[n];
        int cur = 0;
        MinMax(0,1000000000000000000,a,a+n-1);
        cur++;
        while (cur < (n+1)/2){
            //printf("%d ",cur);
            MinMax(a[cur-1]+1,a[n-cur]-1,a+cur,a+n-1-cur);
            cur++;
        }
        long long ans = 0;
        for (int i = 1; i < n; i++){
            //printf("%lld %lld, ",a[i],a[i-1]);
            ans = max(ans,a[i]-a[i-1]);
        }
        return ans;
    }
    else{
        long long lo, hi;
        MinMax(0ll,1000000000000000000ll,&lo,&hi);
        long long diff = (hi-lo)/(n-1) + ((hi-lo)%(n-1)!=0);
        //printf("%lld ",diff);
        vector<long long> v;
        v.push_back(lo);
        long long qs = lo+1, qe = lo+diff;
        long long a,b;
        for (int i = 0; i < n; i++){
            //printf("query %lld %lld\n",qs,qe);
            MinMax(qs,qe,&a,&b);
            qs += diff;
            qe += diff;
            if (a == -1 && b == -1) continue;
            v.push_back(a);
            if (b != a) v.push_back(b);

        }
        v.push_back(hi);
        long long ans = 0;
        for (int i = 1; i < v.size(); i++){
            ans = max(v[i]-v[i-1],ans);
        }
        return ans;
    }
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:46:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < v.size(); i++){
                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 13 ms 1144 KB Output is correct
17 Correct 13 ms 1144 KB Output is correct
18 Correct 13 ms 1144 KB Output is correct
19 Correct 13 ms 1144 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 46 ms 3448 KB Output is correct
22 Correct 46 ms 3356 KB Output is correct
23 Correct 46 ms 3448 KB Output is correct
24 Correct 47 ms 3432 KB Output is correct
25 Correct 39 ms 3064 KB Output is correct
26 Correct 47 ms 3320 KB Output is correct
27 Correct 46 ms 3320 KB Output is correct
28 Correct 47 ms 3448 KB Output is correct
29 Correct 47 ms 3320 KB Output is correct
30 Correct 35 ms 2552 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 17 ms 1272 KB Output is correct
17 Correct 17 ms 1300 KB Output is correct
18 Correct 16 ms 1272 KB Output is correct
19 Correct 16 ms 1244 KB Output is correct
20 Correct 8 ms 632 KB Output is correct
21 Correct 62 ms 3952 KB Output is correct
22 Correct 153 ms 3824 KB Output is correct
23 Correct 61 ms 3824 KB Output is correct
24 Correct 63 ms 3788 KB Output is correct
25 Correct 57 ms 3484 KB Output is correct
26 Correct 62 ms 3824 KB Output is correct
27 Correct 63 ms 3824 KB Output is correct
28 Correct 63 ms 3840 KB Output is correct
29 Correct 62 ms 3824 KB Output is correct
30 Correct 34 ms 2220 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct