답안 #119109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119109 2019-06-20T11:05:11 Z Charis02 Gap (APIO16_gap) C++14
100 / 100
54 ms 2040 KB
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "gap.h"
#define ll long long
#define MAXV 1e18

using namespace std;
long long solve1(int n)
{
    ll ar[n];

    ll curl = 1;
    ll curh = n-2;
    MinMax(0,MAXV,&ar[0],&ar[n-1]);

    while(curl <= curh)
    {
        MinMax(ar[curl-1]+1,ar[curh+1]-1,&ar[curl],&ar[curh]);
        curl++;
        curh--;
    }

    ll dif = 0;

    for(int i = 1;i < n;i++)
    {
        dif = max(dif,ar[i]-ar[i-1]);
    }

    return dif;
}

long long findGap(int T, int N)
{
    if(T == 1)
        return solve1(N);

    long long a,b;
    MinMax(0LL,MAXV,&a,&b);
    ll dif = (b-a)/(N-1)-2;
    ll k = 1;

    while(a < b)
    {
        ll w,x;
        MinMax(a+1,a+dif*k,&x,&w);

        if(w == -1)
        {
            k++;
            continue;
        }

        if(k != 1)
            dif = max(dif,x-a);

        k=1;
        a = w;
    }

    return dif;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 12 ms 768 KB Output is correct
17 Correct 13 ms 768 KB Output is correct
18 Correct 13 ms 768 KB Output is correct
19 Correct 14 ms 768 KB Output is correct
20 Correct 10 ms 768 KB Output is correct
21 Correct 47 ms 1912 KB Output is correct
22 Correct 43 ms 1912 KB Output is correct
23 Correct 45 ms 1912 KB Output is correct
24 Correct 46 ms 1912 KB Output is correct
25 Correct 39 ms 1912 KB Output is correct
26 Correct 46 ms 2040 KB Output is correct
27 Correct 45 ms 1912 KB Output is correct
28 Correct 45 ms 1912 KB Output is correct
29 Correct 45 ms 1912 KB Output is correct
30 Correct 33 ms 1912 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 10 ms 640 KB Output is correct
17 Correct 9 ms 512 KB Output is correct
18 Correct 9 ms 512 KB Output is correct
19 Correct 9 ms 512 KB Output is correct
20 Correct 7 ms 512 KB Output is correct
21 Correct 30 ms 1152 KB Output is correct
22 Correct 31 ms 1144 KB Output is correct
23 Correct 32 ms 1144 KB Output is correct
24 Correct 31 ms 1144 KB Output is correct
25 Correct 54 ms 1152 KB Output is correct
26 Correct 31 ms 1152 KB Output is correct
27 Correct 32 ms 1144 KB Output is correct
28 Correct 31 ms 1144 KB Output is correct
29 Correct 30 ms 1128 KB Output is correct
30 Correct 24 ms 1152 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct