답안 #257357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257357 2020-08-04T07:03:28 Z Fischer Mountains (IOI17_mountains) C++14
컴파일 오류
0 ms 0 KB
#include "mountains.h"
#include <vector>

int maximum_deevs(std::vector<int> y) {
  int n = y.size();
  std::vector<int> last(n, -1);
  std::vector<std::vector<int>> memo(n+1, std::vector<int>(n+1, 0));
  for (int i = 0; i < n; ++i) {
    memo[i][i] = 1;
  }
  for (int len = 2; len <= n; ++len) {
    for (int i = 0; i < n; ++i) {
      int nxt = i + len - 1;
      if (nxt >= n) continue;
      memo[i][nxt] = memo[i+1][nxt];
      if (last[i] == -1 ||
          (last[i] - i) *1ll* (y[nxt] - y[i]) >= (nxt - i) *1ll* (y[last[i]] - y[i])) {
        last[i] = nxt;
      }
      memo[i][nxt] = max(memo[i][nxt], memo[i][last[i]-1] + memo[last[i]+1][nxt]);
    }
  }
  return memo[0][n-1];
}

Compilation message

mountains.cpp: In function 'int maximum_deevs(std::vector<int>)':
mountains.cpp:20:22: error: 'max' was not declared in this scope
       memo[i][nxt] = max(memo[i][nxt], memo[i][last[i]-1] + memo[last[i]+1][nxt]);
                      ^~~
mountains.cpp:20:22: note: suggested alternative:
In file included from /usr/include/c++/7/vector:60:0,
                 from mountains.h:1,
                 from mountains.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   'std::max'
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~