Submission #829456

# Submission time Handle Problem Language Result Execution time Memory
829456 2023-08-18T10:58:47 Z tolbi Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#include "towers.h"

#include <vector>
vector<int> arr;
int n;
int st;
void init(int N, std::vector<int> H) {
    arr=H;
    n=N;
    for (int i = 0; i < N; i++){
        if (H[i]<H[st]) st=i;
    }
}

int max_towers(int L, int R, int D) {
    int mava = -23;
    int ans = 1;
    int nmiva = arr[st];
    for (int i = st+1; i < n; i++){
        if (mava>=nmiva+D && mava>=arr[i]+D){
            mava=-23;
            ans++;
            nmiva=max(nmiva,arr[i]);
        }
        else mava=max(mava,arr[i]);
    }
    mava=-23;
    for (int i = st-1; i >= 0; i--){
        if (mava>=nmiva+D && mava>=arr[i]+D){
            mava=-23;
            ans++;
            nmiva=max(nmiva,arr[i]);
        }
        else mava=max(mava,arr[i]);
    }
    return ans;
}

Compilation message

towers.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> arr;
      | ^~~~~~
towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:8:5: error: 'arr' was not declared in this scope
    8 |     arr=H;
      |     ^~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:18:17: error: 'arr' was not declared in this scope
   18 |     int nmiva = arr[st];
      |                 ^~~
towers.cpp:23:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   23 |             nmiva=max(nmiva,arr[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from towers.h:1,
                 from towers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
towers.cpp:25:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   25 |         else mava=max(mava,arr[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from towers.h:1,
                 from towers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
towers.cpp:32:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   32 |             nmiva=max(nmiva,arr[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from towers.h:1,
                 from towers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
towers.cpp:34:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   34 |         else mava=max(mava,arr[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/vector:60,
                 from towers.h:1,
                 from towers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~