Submission #1160926

#TimeUsernameProblemLanguageResultExecution timeMemory
1160926Kalata_56Gap (APIO16_gap)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>;
#include "gap.h"
long long mas[100011];

long long findGap(int T,int N){
    if(T==1){
    long long maxa=1e18+1;
    long long ans=0;
    long long l=0,r=1e18;
    long long L=0,R=N-1;
    while(L<=R){
        //long long k1,k2;
        MinMax(l,r,&mas[L],&mas[R]);
        L++;
        R--;
        l=mas[L-1]+1;
        r=mas[R+1]-1;
    }
    for(int i=0;i<N-1;i++){
        if(mas[i+1]-mas[i]>ans){
            ans=mas[i+1]-mas[i];
        }
    }
    return ans;
    }
    long long k1,k2;
    long long l=0,r=1e18;
    MinMax(l,r,&k1,&k2);
    if(N==2){
        return k2-k1;
    }

    l=k1+1;
    r=k2-1;
    long long dul=(r-l+1)/(N-1);

    long long L=l,R=L+dul-1;
    long long pre=l-1;
    long long otg=0;
    for(int i=0;i<N-1;i++){
        MinMax(L,R,&k1,&k2);
        otg=max(otg,(k1-pre));

        pre=k2;
        L+=dul;
        R=L+dul-1;
    }
    return max(otg,(r+1)-pre);
}

Compilation message (stderr)

gap.cpp:1:24: warning: extra tokens at end of #include directive
    1 | #include<bits/stdc++.h>;
      |                        ^
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:13: error: 'max' was not declared in this scope
   42 |         otg=max(otg,(k1-pre));
      |             ^~~
gap.cpp:42:13: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from gap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~
gap.cpp:48:12: error: 'max' was not declared in this scope
   48 |     return max(otg,(r+1)-pre);
      |            ^~~
gap.cpp:48:12: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from gap.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   'std::max'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from gap.cpp:1:
/usr/include/c++/11/bits/ranges_algo.h:3011:29: note:   'std::ranges::max'
 3011 |   inline constexpr __max_fn max{};
      |                             ^~~