제출 #1147390

#제출 시각아이디문제언어결과실행 시간메모리
1147390guagua0407Gap (APIO16_gap)C++20
70 / 100
48 ms3256 KiB
#include "gap.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

long long findGap(int T, int n)
{
    ll L,R;
    MinMax(1ll,(ll)1e18,&L,&R);
    ll gap=(R-L-1+(n-1)-1)/(n-1);
    vector<pair<ll,ll>> vec;
    vec.push_back({L,L});
    for(ll l=L+1;l<R;l+=gap){
        ll r=min(R-1,l+gap-1);
        ll mn,mx;
        MinMax(l,r,&mn,&mx);
        if(mn!=-1)vec.push_back({mn,mx});
    }
    vec.push_back({R,R});
    ll ans=0;
    int sz=(int)vec.size();
    for(int i=0;i<sz-1;i++){
        ans=max(ans,vec[i+1].f-vec[i].s);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...