답안 #1005945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005945 2024-06-23T08:38:38 Z vjudge1 Gap (APIO16_gap) C++17
78.5412 / 100
40 ms 1880 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));
}*/
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)/(n-1);
    ll ans=add;ll cs=s;
    while(s<t){
        ll cmn=cs,cmx=cs;
        ll tt=1;
        while(1){
            ll cl=cmn,cr=cmx;
            if(s+(tt-1)*add>t)break;
            MinMax(s+(tt-1)*add,s+tt*add,&cl,&cr);
            if(cl==-1&&cr==-1){tt++;continue;}
            cmn=cl,cmx=cr;break;
        }
        ans=max(ans,cmx-cmn);
        ans=max(ans,cmn-cs);
        s+=(tt)*add;cs=cmx;s=max(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);
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 6 ms 600 KB Output is correct
17 Correct 6 ms 600 KB Output is correct
18 Correct 7 ms 604 KB Output is correct
19 Correct 7 ms 600 KB Output is correct
20 Correct 6 ms 600 KB Output is correct
21 Correct 27 ms 1880 KB Output is correct
22 Correct 27 ms 1880 KB Output is correct
23 Correct 25 ms 1880 KB Output is correct
24 Correct 25 ms 1880 KB Output is correct
25 Correct 23 ms 1880 KB Output is correct
26 Correct 27 ms 1880 KB Output is correct
27 Correct 34 ms 1872 KB Output is correct
28 Correct 25 ms 1876 KB Output is correct
29 Correct 26 ms 1880 KB Output is correct
30 Correct 20 ms 1880 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Partially correct 0 ms 344 KB Partially correct
3 Partially correct 0 ms 344 KB Partially correct
4 Partially correct 0 ms 344 KB Partially correct
5 Partially correct 1 ms 344 KB Partially correct
6 Partially correct 0 ms 344 KB Partially correct
7 Partially correct 0 ms 344 KB Partially correct
8 Partially correct 0 ms 344 KB Partially correct
9 Partially correct 0 ms 344 KB Partially correct
10 Partially correct 0 ms 344 KB Partially correct
11 Partially correct 1 ms 344 KB Partially correct
12 Partially correct 1 ms 344 KB Partially correct
13 Partially correct 1 ms 344 KB Partially correct
14 Partially correct 1 ms 344 KB Partially correct
15 Partially correct 1 ms 344 KB Partially correct
16 Partially correct 8 ms 600 KB Partially correct
17 Partially correct 8 ms 592 KB Partially correct
18 Partially correct 9 ms 600 KB Partially correct
19 Partially correct 8 ms 616 KB Partially correct
20 Partially correct 6 ms 600 KB Partially correct
21 Partially correct 36 ms 1160 KB Partially correct
22 Partially correct 34 ms 1112 KB Partially correct
23 Partially correct 36 ms 1112 KB Partially correct
24 Partially correct 34 ms 1076 KB Partially correct
25 Partially correct 40 ms 1112 KB Partially correct
26 Partially correct 35 ms 1044 KB Partially correct
27 Partially correct 34 ms 1112 KB Partially correct
28 Partially correct 38 ms 1112 KB Partially correct
29 Partially correct 35 ms 1112 KB Partially correct
30 Partially correct 22 ms 1112 KB Partially correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct