Submission #109854

# Submission time Handle Problem Language Result Execution time Memory
109854 2019-05-08T07:30:45 Z boatinw99 Gap (APIO16_gap) C++11
100 / 100
79 ms 2292 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const ll inf = 1e18 ;
vector<ll> v ;
void push(ll cst)
{
    if(cst>-1)v.emplace_back(cst);
}
ll findGap(int T, int N)
{
    ll mn=0,mx=0,l=0,r=inf ;
    v.clear();
    if(T==1)
    {
        for(int i=1;i<=(N+1)/2;i++)
        {
            MinMax(l,r,&mn,&mx);
            push(mn),push(mx);
            l=mn+1,r=mx-1;
        }
        sort(v.begin(),v.end());
        ll ret = 0 ;
        for(int i=1;i<(int)v.size();i++)ret=max(ret,v[i]-v[i-1]);
        return ret ;
    }
    else
    {
        ll ret = 0 ;
        MinMax(l,r,&mn,&mx);
        l=mn,r=mx;
        ll R = r ;
        ll len = (mx-mn)/(N)+1;
        ll ex = l;
        l=l+1;
        r=l+len;
        for(int i=1;l<=R&&i<=N;i++)
        {
            MinMax(l,r,&mn,&mx);
            if(mn!=-1)
            {
                ret = max(ret,mn-ex);
                ex = mx ;
            }
            l=r+1;
            r+=len;
        }
        return ret ;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 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 4 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 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 432 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 16 ms 896 KB Output is correct
17 Correct 15 ms 896 KB Output is correct
18 Correct 16 ms 896 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 14 ms 1024 KB Output is correct
21 Correct 78 ms 2288 KB Output is correct
22 Correct 59 ms 2288 KB Output is correct
23 Correct 64 ms 2288 KB Output is correct
24 Correct 59 ms 2288 KB Output is correct
25 Correct 63 ms 2288 KB Output is correct
26 Correct 66 ms 2288 KB Output is correct
27 Correct 79 ms 2288 KB Output is correct
28 Correct 51 ms 2260 KB Output is correct
29 Correct 55 ms 2288 KB Output is correct
30 Correct 42 ms 2292 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 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 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 19 ms 512 KB Output is correct
17 Correct 20 ms 512 KB Output is correct
18 Correct 18 ms 516 KB Output is correct
19 Correct 18 ms 512 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 71 ms 1144 KB Output is correct
22 Correct 67 ms 1144 KB Output is correct
23 Correct 69 ms 1116 KB Output is correct
24 Correct 64 ms 1144 KB Output is correct
25 Correct 73 ms 1160 KB Output is correct
26 Correct 71 ms 1144 KB Output is correct
27 Correct 67 ms 1144 KB Output is correct
28 Correct 70 ms 1200 KB Output is correct
29 Correct 66 ms 1160 KB Output is correct
30 Correct 33 ms 1152 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct