Language: C++


#include<bits/stdc++.h>

     
    int main(){
        long long int N,K;
       cin >> K >> N;
        vector<long long int> V(N,0);
        vector<long long int>D(N,0);
        for( int i=0;i<N;i++){
            cin>>V[i];
        }
     
        for (int i=0;i<N-1;i++){
            D[i] = V[i+1]-V[i];
        }
        D[N-1] = K - (V[N-1]-V[0]);
       cout<<K - *max_element(D.begin(),D.end())<<std::endl;
        return 0;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |        cin >> K >> N;
      |        ^~~
      |        std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:9: error: 'vector' was not declared in this scope
    8 |         vector<long long int> V(N,0);
      |         ^~~~~~
a.cc:8:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:8:16: error: expected primary-expression before 'long'
    8 |         vector<long long int> V(N,0);
      |                ^~~~
a.cc:9:16: error: expected primary-expression before 'long'
    9 |         vector<long long int>D(N,0);
      |                ^~~~
a.cc:11:18: error: 'V' was not declared in this scope
   11 |             cin>>V[i];
      |                  ^
a.cc:15:13: error: 'D' was not declared in this scope
   15 |             D[i] = V[i+1]-V[i];
      |             ^
a.cc:15:20: error: 'V' was not declared in this scope
   15 |             D[i] = V[i+1]-V[i];
      |                    ^
a.cc:17:9: error: 'D' was not declared in this scope
   17 |         D[N-1] = K - (V[N-1]-V[0]);
      |         ^
a.cc:17:23: error: 'V' was not declared in this scope
   17 |         D[N-1] = K - (V[N-1]-V[0]);
      |                       ^
a.cc:18:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   18 |        cout<<K - *max_element(D.begin(),D.end())<<std::endl;
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:18:19: error: 'max_element' was not declared in this scope; did you mean 'std::max_element'?
   18 |        cout<<K - *max_element(D.begin(),D.end())<<std::endl;
      |                   ^~~~~~~~~~~
      |                   std::max_element
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note: 'std::max_element' declared here
  528 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~