답안 #128172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128172 2019-07-10T13:33:37 Z LittleFlowers__ Gap (APIO16_gap) C++14
100 / 100
84 ms 4076 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define in ({long long x=0;long long c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l,long long r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "TASK"
#define forinc(a,b,c) for(long long a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(long long a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<long long,long long>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

long long findGap(int T,int N){
    if(T==1){
        long long l=0,r=1e18,ret;
        vector<long long> h,t;
        forinc(i,1,(N+1)/2){
            long long x,y;
            MinMax(l,r,&x,&y);
            h.pb(x); t.pb(y);
            l=x+1,r=y-1;
        }
        ret=t.back()-h.back();
        forinc(i,1,h.size()-1) ret=max({ret,h[i]-h[i-1],t[i-1]-t[i]});
        return ret;

    } else{
        long long l=0,r=1e18,ret;
        vector<long long> h,t;
        long long x,y;
        MinMax(l,r,&x,&y);
        h.pb(x); t.pb(y);
        long long gap=(y-x+1)/N+1;
        l=x+1;
        forinc(i,1,(y-x)/gap+1){
            MinMax(l,min(t.back()-1,l+gap-1),&x,&y);
            if(x!=-1) h.pb(x);
            if(y!=-1) h.pb(y);
            l+=gap;
        }
        ret=t.back()-h.back();
        forinc(i,1,h.size()-1) ret=max(ret,h[i]-h[i-1]);
        return ret;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 276 KB Output is correct
6 Correct 2 ms 248 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 16 ms 1272 KB Output is correct
17 Correct 16 ms 1272 KB Output is correct
18 Correct 16 ms 1272 KB Output is correct
19 Correct 16 ms 1272 KB Output is correct
20 Correct 12 ms 1016 KB Output is correct
21 Correct 59 ms 3104 KB Output is correct
22 Correct 58 ms 3080 KB Output is correct
23 Correct 58 ms 3108 KB Output is correct
24 Correct 58 ms 3108 KB Output is correct
25 Correct 50 ms 2852 KB Output is correct
26 Correct 58 ms 3108 KB Output is correct
27 Correct 59 ms 3104 KB Output is correct
28 Correct 58 ms 3108 KB Output is correct
29 Correct 58 ms 3108 KB Output is correct
30 Correct 44 ms 2724 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 420 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 21 ms 1408 KB Output is correct
17 Correct 21 ms 1528 KB Output is correct
18 Correct 21 ms 1400 KB Output is correct
19 Correct 21 ms 1404 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 84 ms 3312 KB Output is correct
22 Correct 80 ms 3312 KB Output is correct
23 Correct 82 ms 3312 KB Output is correct
24 Correct 81 ms 3400 KB Output is correct
25 Correct 77 ms 4076 KB Output is correct
26 Correct 80 ms 3056 KB Output is correct
27 Correct 79 ms 3056 KB Output is correct
28 Correct 80 ms 3056 KB Output is correct
29 Correct 80 ms 3056 KB Output is correct
30 Correct 38 ms 2172 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct