답안 #101703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101703 2019-03-19T14:12:39 Z ae04071 Gap (APIO16_gap) C++11
100 / 100
90 ms 1276 KB
#include "gap.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using namespace std;
using lli=long long;
using pll=pair<lli,lli>;

const lli INF=1000000000000000000ll;

lli sub1(int n) {
    lli mx=0, lv=-1, rv=INF+1;
    for(int i=0;i<(n+1)/2;i++) {
        lli s=lv, t=rv, l, r;
        MinMax(s+1, t-1, &l, &r);
        if(i!=0) {
            mx = max(mx, l-lv);
            mx = max(mx, rv-r);
        }
        lv = l; rv = r;
    }
    if(!(n&1)) mx = max(mx, rv-lv);
    return mx;
}
lli sub2(int n) {
    lli s=0,f=INF,l,r;
    MinMax(s, f, &l, &r);
    
    lli seg = (r-l)/n,mx=0;
    s=l+1;
    while(s<r) {
        f = s+seg;
        if(f >= r) f=r-1;
        
        lli lv,rv;
        MinMax(s, f, &lv, &rv);
        if(lv!=-1) {
            mx = max(mx, lv-l);
            l = rv;
        }
        s=f+1;
    }
    mx = max(mx, r-l);
    return mx;
}

long long findGap(int T, int N)
{
    if(T==1) return sub1(N);
    else return sub2(N);
    
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 356 KB Output is correct
6 Correct 2 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 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 15 ms 512 KB Output is correct
17 Correct 14 ms 548 KB Output is correct
18 Correct 12 ms 512 KB Output is correct
19 Correct 19 ms 580 KB Output is correct
20 Correct 10 ms 512 KB Output is correct
21 Correct 51 ms 1088 KB Output is correct
22 Correct 60 ms 1276 KB Output is correct
23 Correct 53 ms 1144 KB Output is correct
24 Correct 56 ms 1144 KB Output is correct
25 Correct 42 ms 1152 KB Output is correct
26 Correct 50 ms 1144 KB Output is correct
27 Correct 52 ms 1272 KB Output is correct
28 Correct 53 ms 1144 KB Output is correct
29 Correct 52 ms 1144 KB Output is correct
30 Correct 41 ms 1152 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 19 ms 512 KB Output is correct
17 Correct 21 ms 512 KB Output is correct
18 Correct 18 ms 512 KB Output is correct
19 Correct 24 ms 556 KB Output is correct
20 Correct 10 ms 512 KB Output is correct
21 Correct 64 ms 1164 KB Output is correct
22 Correct 64 ms 1144 KB Output is correct
23 Correct 70 ms 1156 KB Output is correct
24 Correct 65 ms 1152 KB Output is correct
25 Correct 60 ms 1152 KB Output is correct
26 Correct 90 ms 1132 KB Output is correct
27 Correct 90 ms 1144 KB Output is correct
28 Correct 67 ms 1164 KB Output is correct
29 Correct 65 ms 1164 KB Output is correct
30 Correct 36 ms 1164 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct