Submission #910453

# Submission time Handle Problem Language Result Execution time Memory
910453 2024-01-18T05:11:23 Z ibm2006 Gap (APIO16_gap) C++17
89.0376 / 100
48 ms 3544 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,y-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 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 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 2880 KB Output is correct
17 Correct 9 ms 2688 KB Output is correct
18 Correct 9 ms 2672 KB Output is correct
19 Correct 8 ms 2696 KB Output is correct
20 Correct 7 ms 2664 KB Output is correct
21 Correct 31 ms 3268 KB Output is correct
22 Correct 30 ms 3260 KB Output is correct
23 Correct 31 ms 3268 KB Output is correct
24 Correct 31 ms 3268 KB Output is correct
25 Correct 28 ms 3244 KB Output is correct
26 Correct 31 ms 3256 KB Output is correct
27 Correct 32 ms 3268 KB Output is correct
28 Correct 30 ms 3440 KB Output is correct
29 Correct 32 ms 3544 KB Output is correct
30 Correct 25 ms 3244 KB Output is correct
31 Correct 0 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 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 10 ms 644 KB Output is correct
17 Correct 10 ms 640 KB Output is correct
18 Correct 10 ms 640 KB Output is correct
19 Correct 10 ms 648 KB Output is correct
20 Partially correct 5 ms 616 KB Partially correct
21 Correct 44 ms 1228 KB Output is correct
22 Correct 42 ms 1216 KB Output is correct
23 Correct 48 ms 1200 KB Output is correct
24 Correct 44 ms 1432 KB Output is correct
25 Correct 39 ms 1196 KB Output is correct
26 Correct 44 ms 1228 KB Output is correct
27 Correct 41 ms 1212 KB Output is correct
28 Correct 41 ms 1212 KB Output is correct
29 Correct 42 ms 1172 KB Output is correct
30 Partially correct 25 ms 1168 KB Partially correct
31 Correct 1 ms 532 KB Output is correct
32 Correct 1 ms 344 KB Output is correct