답안 #876552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876552 2023-11-21T23:40:32 Z AlphaMale06 Gap (APIO16_gap) C++14
30 / 100
38 ms 3884 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+2;
                    }
                    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 0 ms 2392 KB Output is correct
6 Correct 0 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 0 ms 2440 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 2484 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 2752 KB Output is correct
17 Correct 7 ms 2752 KB Output is correct
18 Correct 8 ms 2784 KB Output is correct
19 Correct 7 ms 2580 KB Output is correct
20 Correct 6 ms 2572 KB Output is correct
21 Correct 28 ms 3632 KB Output is correct
22 Correct 30 ms 3624 KB Output is correct
23 Correct 31 ms 3632 KB Output is correct
24 Correct 31 ms 3884 KB Output is correct
25 Correct 25 ms 3616 KB Output is correct
26 Correct 28 ms 3624 KB Output is correct
27 Correct 31 ms 3624 KB Output is correct
28 Correct 28 ms 3628 KB Output is correct
29 Correct 28 ms 3632 KB Output is correct
30 Correct 23 ms 3620 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Incorrect 0 ms 2392 KB Output isn't correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 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 5 ms 2588 KB Output is correct
17 Correct 5 ms 2756 KB Output is correct
18 Correct 4 ms 2584 KB Output is correct
19 Correct 5 ms 2580 KB Output is correct
20 Correct 2 ms 2556 KB Output is correct
21 Correct 17 ms 2984 KB Output is correct
22 Correct 17 ms 2860 KB Output is correct
23 Correct 16 ms 2860 KB Output is correct
24 Correct 17 ms 2660 KB Output is correct
25 Correct 38 ms 2852 KB Output is correct
26 Correct 17 ms 2852 KB Output is correct
27 Correct 18 ms 2868 KB Output is correct
28 Correct 17 ms 2856 KB Output is correct
29 Correct 20 ms 2856 KB Output is correct
30 Correct 8 ms 2856 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct