Submission #260665

# Submission time Handle Problem Language Result Execution time Memory
260665 2020-08-10T17:04:52 Z A02 Wall (IOI14_wall) C++14
Compilation error
0 ms 0 KB
#include "wall.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){

    for (int i = 0; i < n; i++){
        finalHeight[i] = 0;
    }
    for (int i = 0; i < k; i++){
        for (int x = left[i]; x <= right[i]; x++){
            if (op[i] == 1){
                finalHeight[x] = max(finalHeight[i], height[i]);
            } else {
                finalHeight[x] = min(finalHeight[i], height[i]);
            }
        }
    }

    return;
}

Compilation message

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:16:34: error: 'max' was not declared in this scope
                 finalHeight[x] = max(finalHeight[i], height[i]);
                                  ^~~
wall.cpp:16:34: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from wall.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
wall.cpp:18:34: error: 'min' was not declared in this scope
                 finalHeight[x] = min(finalHeight[i], height[i]);
                                  ^~~
wall.cpp:18:34: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from wall.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   'std::min'
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~