Submission #910447

# Submission time Handle Problem Language Result Execution time Memory
910447 2024-01-18T05:10:38 Z ibm2006 Gap (APIO16_gap) C++17
30 / 100
44 ms 3564 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,s,l,r,x,y,z,w,a[1100000],i,j,k,m,mx,gap;
long long findGap(int T, int N)
{
    n=N;
    if(T==1)
    {
        l=0;
        r=1e18-1;
        x=1;
        y=n;
        while(l<r)
        {
            MinMax(l,r,&l,&r);
            a[x]=l;
            a[y]=r;
            x++;
            y--;
            if(l==r||x>y)
                break;
            l++;
            r--;
        }
        for(i=1;i<n;i++)
        {
            s=max(s,a[i+1]-a[i]);
        }
        return s;
    }
    l=0;
    r=1e18-1;
    MinMax(l,r,&x,&y);
    if(n==2)
    {
        return y-x;
    }
	gap=(y-x)/(n-1);
	l=x+1;
	mx=x;
	//printf("%lld,%lld\n",x,y);
	while(1)
    {
        r=min(l+gap-1,y-1);
        //printf("(%lld,%lld)\n",l,r);
        MinMax(l,r,&z,&w);
        if(z==-1)
        {
            l+=gap;
            if(l>=y)
                break;
            continue;
        }
        s=max(s,z-mx);
        mx=w;
        l+=gap;
        if(l>=y)
            break;
    }
    s=max(s,r-mx);
    return s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 596 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 8 ms 2692 KB Output is correct
17 Correct 8 ms 2692 KB Output is correct
18 Correct 9 ms 2684 KB Output is correct
19 Correct 8 ms 2696 KB Output is correct
20 Correct 7 ms 2668 KB Output is correct
21 Correct 33 ms 3564 KB Output is correct
22 Correct 30 ms 3276 KB Output is correct
23 Correct 33 ms 3332 KB Output is correct
24 Correct 31 ms 3504 KB Output is correct
25 Correct 27 ms 3268 KB Output is correct
26 Correct 30 ms 3256 KB Output is correct
27 Correct 30 ms 3276 KB Output is correct
28 Correct 32 ms 3240 KB Output is correct
29 Correct 30 ms 3424 KB Output is correct
30 Correct 25 ms 3236 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 10 ms 644 KB Output is correct
17 Correct 11 ms 644 KB Output is correct
18 Correct 10 ms 636 KB Output is correct
19 Correct 10 ms 648 KB Output is correct
20 Partially correct 5 ms 608 KB Partially correct
21 Correct 42 ms 1208 KB Output is correct
22 Correct 42 ms 1212 KB Output is correct
23 Correct 42 ms 1184 KB Output is correct
24 Correct 41 ms 1212 KB Output is correct
25 Correct 39 ms 1188 KB Output is correct
26 Correct 43 ms 1240 KB Output is correct
27 Correct 44 ms 1216 KB Output is correct
28 Correct 41 ms 1220 KB Output is correct
29 Correct 42 ms 1212 KB Output is correct
30 Partially correct 25 ms 1192 KB Partially correct
31 Incorrect 1 ms 344 KB Output isn't correct
32 Correct 0 ms 344 KB Output is correct