답안 #361297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
361297 2021-01-29T07:52:21 Z tuank99lhp Gap (APIO16_gap) C++17
100 / 100
65 ms 2156 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long b[100005];
 
long long findGap(int T,int N)
{
    if (T==1)
    {
        b[0]=-1;
        b[N+1]=1e18;
        ++b[N+1];
        for (int i=1;i<=(N+1)/2;++i) {
                if (i>N/2)
                {
                    long long x,y;
                    MinMax(b[i-1]+1,b[N-i+2]-1,&x,&y);
                    b[i]=x;
                }
                else MinMax(b[i-1]+1,b[N-i+2]-1,&b[i],&b[N-i+1]);
        }
        long long kq=0;
        for (int i=2;i<=N;++i) kq=max(kq,b[i]-b[i-1]);
        return kq;
    }
    else
    {
        long long x,y;
        MinMax(0,1e18,&x,&y);
        long long X=(y-x+N-1)/N;
        long long kq=X;
        b[0]=x;
        for (int i=1;i<=N;++i)
        {
            if (x+X*(i-1)+1>y) break;
            long long h,k;
            MinMax(x+X*(i-1)+1,min(y,x+X*i),&h,&k);
            if (k==-1) b[i]=b[i-1];else b[i]=k;
            kq=max(kq,h-b[i-1]);
        }
        return kq;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 12 ms 748 KB Output is correct
17 Correct 11 ms 748 KB Output is correct
18 Correct 12 ms 768 KB Output is correct
19 Correct 11 ms 748 KB Output is correct
20 Correct 9 ms 748 KB Output is correct
21 Correct 44 ms 1900 KB Output is correct
22 Correct 45 ms 1948 KB Output is correct
23 Correct 47 ms 2012 KB Output is correct
24 Correct 45 ms 1900 KB Output is correct
25 Correct 39 ms 1900 KB Output is correct
26 Correct 49 ms 1900 KB Output is correct
27 Correct 46 ms 1900 KB Output is correct
28 Correct 45 ms 1900 KB Output is correct
29 Correct 45 ms 1900 KB Output is correct
30 Correct 37 ms 1900 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 16 ms 748 KB Output is correct
17 Correct 15 ms 748 KB Output is correct
18 Correct 15 ms 748 KB Output is correct
19 Correct 15 ms 748 KB Output is correct
20 Correct 7 ms 748 KB Output is correct
21 Correct 65 ms 1984 KB Output is correct
22 Correct 62 ms 1900 KB Output is correct
23 Correct 65 ms 1948 KB Output is correct
24 Correct 61 ms 2052 KB Output is correct
25 Correct 58 ms 2156 KB Output is correct
26 Correct 62 ms 1900 KB Output is correct
27 Correct 62 ms 1900 KB Output is correct
28 Correct 62 ms 1900 KB Output is correct
29 Correct 64 ms 1988 KB Output is correct
30 Correct 33 ms 1900 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct