답안 #403686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403686 2021-05-13T11:16:07 Z teehandsome Gap (APIO16_gap) C++11
100 / 100
64 ms 1856 KB
#include "gap.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,t;

long long findGap(int T, int N)
{
    n=N,t=T;
    if(T==1) {
        vector<ll> a(n);
        ll l=0,r=1e18;
        int li=0,ri=n-1;
        for(int i=0;i<(n+1)/2;i++) {
            if(li>ri) break;
            ll mn,mx;
            MinMax(l,r,&mn,&mx);
            a[li++]=mn;
            a[ri--]=mx;
            l=mn+1;
            r=mx-1;
        }
        ll ans=0;
        for(int i=1;i<n;i++) {
            ans=max(ans,a[i]-a[i-1]);
        }
        return ans;
    }
    //T=2

    ll mn,mx;
    ll templ=0,tempr=1e18;
    MinMax(templ,tempr,&mn,&mx);
    ll block=(mx-mn)/(n-1);
    ll ans=block;
    ll past=mn;
    ll a,b;
    for(ll i=mn+1;i<=mx-1;) {
        MinMax(i,i+block,&a,&b);
//        debug(i,i+block,a,b);
        ans=max(ans,a-past);
        if(b!=-1) past=b;
        i=i+block+1;

    }
    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 12 ms 712 KB Output is correct
17 Correct 11 ms 584 KB Output is correct
18 Correct 12 ms 632 KB Output is correct
19 Correct 13 ms 712 KB Output is correct
20 Correct 9 ms 584 KB Output is correct
21 Correct 49 ms 1808 KB Output is correct
22 Correct 44 ms 1768 KB Output is correct
23 Correct 44 ms 1856 KB Output is correct
24 Correct 44 ms 1820 KB Output is correct
25 Correct 43 ms 1744 KB Output is correct
26 Correct 47 ms 1756 KB Output is correct
27 Correct 49 ms 1764 KB Output is correct
28 Correct 49 ms 1816 KB Output is correct
29 Correct 44 ms 1768 KB Output is correct
30 Correct 36 ms 1828 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 200 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 2 ms 328 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 20 ms 488 KB Output is correct
17 Correct 15 ms 456 KB Output is correct
18 Correct 16 ms 456 KB Output is correct
19 Correct 15 ms 456 KB Output is correct
20 Correct 8 ms 456 KB Output is correct
21 Correct 59 ms 1048 KB Output is correct
22 Correct 59 ms 960 KB Output is correct
23 Correct 64 ms 1088 KB Output is correct
24 Correct 60 ms 960 KB Output is correct
25 Correct 55 ms 1052 KB Output is correct
26 Correct 60 ms 1052 KB Output is correct
27 Correct 60 ms 960 KB Output is correct
28 Correct 61 ms 1056 KB Output is correct
29 Correct 61 ms 960 KB Output is correct
30 Correct 34 ms 1080 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct