답안 #82272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82272 2018-10-29T17:20:00 Z Bodo171 Gap (APIO16_gap) C++14
30 / 100
78 ms 2172 KB
#include "gap.h"
#include <iostream>
#include <climits>
using namespace std;
const int nmax=100005;
long long v[nmax];
long long mx,st,dr,act,inf,sup,i;
int n;
long long findGap(int T, int N)
{
    n=N;
    if(T==1)
    {
        mx=0;
        v[0]=-1;v[n+1]=1LL*1e18;
        v[n+1]++;//don't mess with 1e18
        for(i=1;i<=n/2;i++)
        {
            MinMax(v[i-1]+1,v[n-i+2]-1,&v[i],&v[n-i+1]);
        }
        if((n&1))
        {
            MinMax(v[n/2]+1,v[n/2+2]-1,&v[(n+1)/2],&sup);
        }
        for(i=1;i<n;i++)
            mx=1LL*max(mx,1LL*v[i+1]-v[i]);
        return mx;
    }
    act=-1;
    long long mare=1LL*1e18;
    MinMax(0,mare,&inf,&sup);
    long long nn=n,ans=0;
    long long def=1LL*(sup-inf)/(nn-1);
    if((sup-inf)%(nn-1))
        def+=1LL;
    act=1LL*inf;ans=1LL*def;
    for(long long i=2;i<=n-1&&act+1LL*(i-1)*def<=sup;i++)
    {
        bool ok=1;
        while(ok&&act+1LL*(i-1)*def<=sup)
        {
            ok=0;
            MinMax(act+1,act+1LL*i*def,&st,&dr);
            if(dr!=-1)
            {
                ans=1LL*max(1LL*st-act,ans);
                act=1LL*dr;
                ok=1;
            }
        }
    }
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 472 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 3 ms 508 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 2 ms 592 KB Output is correct
8 Correct 3 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 3 ms 720 KB Output is correct
11 Correct 3 ms 720 KB Output is correct
12 Correct 3 ms 720 KB Output is correct
13 Correct 3 ms 720 KB Output is correct
14 Correct 3 ms 720 KB Output is correct
15 Correct 3 ms 720 KB Output is correct
16 Correct 15 ms 960 KB Output is correct
17 Correct 15 ms 1064 KB Output is correct
18 Correct 16 ms 1064 KB Output is correct
19 Correct 15 ms 1064 KB Output is correct
20 Correct 12 ms 1064 KB Output is correct
21 Correct 68 ms 2172 KB Output is correct
22 Correct 76 ms 2172 KB Output is correct
23 Correct 57 ms 2172 KB Output is correct
24 Correct 56 ms 2172 KB Output is correct
25 Correct 50 ms 2172 KB Output is correct
26 Correct 59 ms 2172 KB Output is correct
27 Correct 78 ms 2172 KB Output is correct
28 Correct 78 ms 2172 KB Output is correct
29 Correct 59 ms 2172 KB Output is correct
30 Correct 47 ms 2172 KB Output is correct
31 Correct 2 ms 2172 KB Output is correct
32 Correct 2 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2172 KB Output is correct
2 Correct 2 ms 2172 KB Output is correct
3 Incorrect 2 ms 2172 KB Output isn't correct
4 Correct 2 ms 2172 KB Output is correct
5 Correct 2 ms 2172 KB Output is correct
6 Correct 2 ms 2172 KB Output is correct
7 Correct 2 ms 2172 KB Output is correct
8 Correct 2 ms 2172 KB Output is correct
9 Correct 2 ms 2172 KB Output is correct
10 Correct 3 ms 2172 KB Output is correct
11 Correct 2 ms 2172 KB Output is correct
12 Correct 3 ms 2172 KB Output is correct
13 Correct 3 ms 2172 KB Output is correct
14 Correct 3 ms 2172 KB Output is correct
15 Correct 3 ms 2172 KB Output is correct
16 Correct 11 ms 2172 KB Output is correct
17 Correct 11 ms 2172 KB Output is correct
18 Correct 12 ms 2172 KB Output is correct
19 Correct 11 ms 2172 KB Output is correct
20 Correct 8 ms 2172 KB Output is correct
21 Correct 38 ms 2172 KB Output is correct
22 Correct 39 ms 2172 KB Output is correct
23 Correct 36 ms 2172 KB Output is correct
24 Correct 36 ms 2172 KB Output is correct
25 Correct 51 ms 2172 KB Output is correct
26 Correct 36 ms 2172 KB Output is correct
27 Correct 37 ms 2172 KB Output is correct
28 Correct 37 ms 2172 KB Output is correct
29 Correct 35 ms 2172 KB Output is correct
30 Correct 24 ms 2172 KB Output is correct
31 Correct 2 ms 2172 KB Output is correct
32 Correct 2 ms 2172 KB Output is correct