답안 #526054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526054 2022-02-13T15:57:52 Z benjaminkleyn 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"
#include <vector>

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    int n = c.size();
    std::vector<int> s(n);
    int q = l.size();

    for (int j = 0; j < q; j++)
        for (int k = l[j]; k <= r[j]; k++)
            s[k] += v[j], s[k] = max(s[k], 0), s[k] = min(s[k], c[k]);

    return s;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:12:34: error: 'max' was not declared in this scope; did you mean 'std::max'?
   12 |             s[k] += v[j], s[k] = max(s[k], 0), s[k] = min(s[k], c[k]);
      |                                  ^~~
      |                                  std::max
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.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)
      |     ^~~
candies.cpp:12:55: error: 'min' was not declared in this scope; did you mean 'std::min'?
   12 |             s[k] += v[j], s[k] = max(s[k], 0), s[k] = min(s[k], c[k]);
      |                                                       ^~~
      |                                                       std::min
In file included from /usr/include/c++/10/vector:60,
                 from candies.h:1,
                 from candies.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~