제출 #1341081

#제출 시각아이디문제언어결과실행 시간메모리
1341081aritro_Gap (APIO16_gap)C++20
100 / 100
47 ms3240 KiB
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;

typedef long long ll;
#define pb push_back

ll MinMax(int s,int t,int a,int b);

ll findGap(int t,int n){
    if(t==1){
        ll l=-1,r=2e18;
        vector<ll> a;
        for(int i=0;i<(n+1)/2;i++){
            MinMax(l+1,r-1,&l,&r);
            a.pb(l);
            if(l!=r) a.pb(r);
        }
        sort(a.begin(),a.end());
        ll ans=0;
        for(int i=0;i<n-1;i++) ans=max(ans,a[i+1]-a[i]);
        return ans;
    }else if(t==2){
        ll ans=1;
        ll l,r;
        MinMax(1,1e18,&l,&r);
        ll len=r-l;
        ll gap=(len+n-2)/(n-1);
        ans=max(gap, ans);
        vector<ll> arr={l};
        ll fir=l+1,sec=l+1+gap;
        ll o,t;
        while(fir<=r){
            MinMax(fir,sec,&o,&t);
            if(o!=-1) arr.pb(o);
            if(t!=-1) arr.pb(t);
            fir+=gap+1,sec+=gap+1;
        }
        for(int i=1;i<arr.size();i++) ans=max(ans,arr[i]-arr[i-1]);
        return ans;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...