답안 #36929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36929 2017-12-18T17:34:55 Z imaxblue Gap (APIO16_gap) C++14
100 / 100
99 ms 5140 KB
#include<iostream>
#include "gap.h"
using namespace std;
#define ll long long

int c;
ll b, x, y, pre, lo=0, ans, hi=1000000000000000000LL;
/*void MinMax(ll lo, ll hi, ll *x, ll *y){
    c++;
    if (lo>728704890713443211 || hi<29659227736649406){
        *x=*y=-1;
        return;
    }
    if (lo<=29659227736649406) *x=29659227736649406;
    else *x=728704890713443211;
    if (hi>=728704890713443211) *y=728704890713443211;
    else *y=29659227736649406;
}*/
ll findGap(int t, int n){
    MinMax(lo, hi, &lo, &hi);
    if (t==1){
        if (n<3) return hi-lo;
        for (int l=0; l<(n-1)/2; ++l){
            MinMax(lo+1, max(lo+1, hi-1), &x, &y);
            if (x==-1) break;
            ans=max(ans, max(x-lo, hi-y));
            if (x==y) break;
            if (l==(n-1)/2-1) ans=max(ans, y-x);
            lo=x; hi=y;
        }
        return ans;
    }
    b=(hi-lo+n-2)/n;
    pre=lo; ans=0;
    //cout << lo << ' ' << hi << ' ' << b << endl;
    for (ll l=lo+1; l<hi; l+=b){
        //cout << l << ' ' << endl;
        MinMax(l, min(hi, l+b-1), &x, &y);
        if (x==-1) continue;
        ans=max(ans, x-pre); pre=y;
    }
    ans=max(ans, hi-pre);
    return ans;
}
/*int main(){
    cout << findGap(1, 2) << ' '; cout << c;
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5140 KB Output is correct
2 Correct 0 ms 5140 KB Output is correct
3 Correct 0 ms 5140 KB Output is correct
4 Correct 0 ms 5140 KB Output is correct
5 Correct 0 ms 5140 KB Output is correct
6 Correct 0 ms 5140 KB Output is correct
7 Correct 0 ms 5140 KB Output is correct
8 Correct 0 ms 5140 KB Output is correct
9 Correct 0 ms 5140 KB Output is correct
10 Correct 0 ms 5140 KB Output is correct
11 Correct 0 ms 5140 KB Output is correct
12 Correct 0 ms 5140 KB Output is correct
13 Correct 0 ms 5140 KB Output is correct
14 Correct 0 ms 5140 KB Output is correct
15 Correct 0 ms 5140 KB Output is correct
16 Correct 9 ms 5140 KB Output is correct
17 Correct 16 ms 5140 KB Output is correct
18 Correct 6 ms 5140 KB Output is correct
19 Correct 13 ms 5140 KB Output is correct
20 Correct 9 ms 5140 KB Output is correct
21 Correct 59 ms 5140 KB Output is correct
22 Correct 53 ms 5140 KB Output is correct
23 Correct 53 ms 5140 KB Output is correct
24 Correct 53 ms 5140 KB Output is correct
25 Correct 49 ms 5140 KB Output is correct
26 Correct 63 ms 5140 KB Output is correct
27 Correct 56 ms 5140 KB Output is correct
28 Correct 49 ms 5140 KB Output is correct
29 Correct 66 ms 5140 KB Output is correct
30 Correct 39 ms 5140 KB Output is correct
31 Correct 0 ms 5140 KB Output is correct
32 Correct 0 ms 5140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5140 KB Output is correct
2 Correct 0 ms 5140 KB Output is correct
3 Correct 0 ms 5140 KB Output is correct
4 Correct 0 ms 5140 KB Output is correct
5 Correct 0 ms 5140 KB Output is correct
6 Correct 0 ms 5140 KB Output is correct
7 Correct 0 ms 5140 KB Output is correct
8 Correct 0 ms 5140 KB Output is correct
9 Correct 0 ms 5140 KB Output is correct
10 Correct 0 ms 5140 KB Output is correct
11 Correct 0 ms 5140 KB Output is correct
12 Correct 0 ms 5140 KB Output is correct
13 Correct 0 ms 5140 KB Output is correct
14 Correct 0 ms 5140 KB Output is correct
15 Correct 0 ms 5140 KB Output is correct
16 Correct 26 ms 5140 KB Output is correct
17 Correct 19 ms 5140 KB Output is correct
18 Correct 16 ms 5140 KB Output is correct
19 Correct 19 ms 5140 KB Output is correct
20 Correct 13 ms 5140 KB Output is correct
21 Correct 79 ms 5140 KB Output is correct
22 Correct 79 ms 5140 KB Output is correct
23 Correct 76 ms 5140 KB Output is correct
24 Correct 66 ms 5140 KB Output is correct
25 Correct 69 ms 5140 KB Output is correct
26 Correct 76 ms 5140 KB Output is correct
27 Correct 69 ms 5140 KB Output is correct
28 Correct 73 ms 5140 KB Output is correct
29 Correct 99 ms 5140 KB Output is correct
30 Correct 36 ms 5140 KB Output is correct
31 Correct 0 ms 5140 KB Output is correct
32 Correct 0 ms 5140 KB Output is correct