답안 #876555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876555 2023-11-21T23:56:47 Z AlphaMale06 Gap (APIO16_gap) C++14
30 / 100
38 ms 3876 KB
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll=long long;

long long findGap(int subt, int n){
    if(subt==1){
        ll mn=0;
        ll mx=1e18;
        ll a[n];
        for(int i=0; i< (n+1)/2; i++){
            MinMax(mn, mx, &mn, &mx);
            a[i]=mn;
            a[n-i-1]=mx;
            mn++;
            mx--;
        }
        ll ans=0;
        for(int i=1; i<n; i++){
            ans=max(ans, a[i]-a[i-1]);
        }
        return ans;
    }
    else{
        ll mn=0; ll mx=1e18;
        MinMax(mn, mx, &mn, &mx);
        ll mngap=(mx-mn+n-2)/(n-1)+1;
        ll l=mn+1;
        while(true){
            ll qmn=l;
            if(mx-qmn+1<mngap)break;
            ll qmx=l+mngap-1;
            MinMax(qmn, qmx, &qmn, &qmx);
            if(qmx==-1){
                while(true){
                    ll posgp=2*mngap;
                    ll qmn2=l;
                    ll qmx2=l+posgp-1;
                    if(qmx2>=mx){
                        qmx2=mx-1;
                        MinMax(qmn2, qmx2, &qmn2, &qmx2);
                        if(qmx2==-1){
                            return mx-l+1;
                        }
                        else{
                            return qmx2-l+1;
                        }
                    }
                    MinMax(qmn2, qmx2, &qmn2, &qmx2);
                    if(qmx2==-1){
                        mngap=posgp+1;
                    }
                    else{
                        mngap=qmn2-l+2;
                        l=qmx2+1;
                        break;
                    }
                }
            }
            else{
                if(qmx==qmn && qmx==l+mngap-1){
                    mngap++;
                }
                l=qmx+1;
            }
        }
        return mngap-1;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 7 ms 2592 KB Output is correct
17 Correct 7 ms 2592 KB Output is correct
18 Correct 7 ms 2588 KB Output is correct
19 Correct 7 ms 2752 KB Output is correct
20 Correct 6 ms 2572 KB Output is correct
21 Correct 28 ms 3640 KB Output is correct
22 Correct 28 ms 3628 KB Output is correct
23 Correct 28 ms 3636 KB Output is correct
24 Correct 29 ms 3644 KB Output is correct
25 Correct 25 ms 3656 KB Output is correct
26 Correct 28 ms 3632 KB Output is correct
27 Correct 28 ms 3876 KB Output is correct
28 Correct 28 ms 3648 KB Output is correct
29 Correct 28 ms 3620 KB Output is correct
30 Correct 23 ms 3620 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Incorrect 1 ms 2392 KB Output isn't correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 6 ms 2580 KB Output is correct
17 Correct 5 ms 2580 KB Output is correct
18 Correct 7 ms 2744 KB Output is correct
19 Correct 4 ms 2580 KB Output is correct
20 Correct 2 ms 2792 KB Output is correct
21 Correct 16 ms 2856 KB Output is correct
22 Correct 16 ms 2860 KB Output is correct
23 Correct 17 ms 2860 KB Output is correct
24 Correct 16 ms 2864 KB Output is correct
25 Correct 38 ms 2860 KB Output is correct
26 Correct 17 ms 2856 KB Output is correct
27 Correct 19 ms 2860 KB Output is correct
28 Correct 17 ms 2860 KB Output is correct
29 Correct 16 ms 2860 KB Output is correct
30 Correct 8 ms 2852 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct