답안 #1005932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005932 2024-06-23T08:12:22 Z vjudge1 Gap (APIO16_gap) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
//#include "gap.h"
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
using namespace std;
const int mxn=3e5+5;
multiset<ll>ms;
void MinMax(ll x,ll y,ll &x1,ll &y1){
    x1=*ms.lower_bound(x);
    y1=*prev(ms.upper_bound(y));
    if(x1>y1)x1=-1,y1=-1;
}
ll sol1(int n){
    ll mn=0,mx=1e18;
    int l=1,r=n;
    ll a[n+1];
    while(l<=r){
        ll s,t;
        MinMax(mn,mx,s,t);
        a[l++]=s;a[r--]=t;
        mn=s+1,mx=t-1;
    }ll ans=0;
    for(int i=2;i<=n;i++)ans=max(ans,a[i]-a[i-1]);
    return ans;
}
ll sol2(int n){
    ll mn=0,mx=1e18;
    ll s,t;MinMax(mn,mx,s,t);
    ll add = (t-s-1)/(n-1)+1;
    ll ans=add;
    while(s<t){
        ll cmn=s,cmx=s;
        ll tt=2;
        while(1){
            ll cl=cmn,cr=cmx;
            cout<<cl<<' '<<cr<<'\n';
            MinMax(s+(tt-1)*add,s+tt*add,cl,cr);
            if(cl==-1&&cr==-1){tt++;continue;}
            if(cl==cr&&cl==s){tt++;continue;}
            cmn=cl,cmx=cr;break;
        }
        if(cmn==cmx)cmn=s;
        ans=max(ans,cmx-cmn);
        s=cmx;
    }return ans;
}
long long findGap(int T, int N){
    if(T==1)return sol1(N);
    else return sol2(N);
}
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        int x;cin>>x;ms.insert(x);
    }for(auto it : ms)cout<<it<<' ';cout<<'\n';
    cout<<findGap(2,n);
}

Compilation message

/usr/bin/ld: /tmp/ccTys09W.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPvVoMS.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status