제출 #569490

#제출 시각아이디문제언어결과실행 시간메모리
569490Turkhuu도로 폐쇄 (APIO21_roads)C++17
컴파일 에러
0 ms0 KiB
#include "roads.h" #include <bits/stdc++.h> std::vector<long long> minimum_closure_costs(int n, std::vector<int> u, std::vector<int> v, std::vector<int> w){ bool subtask1 = true; for(int i = 0; i < n - 1; i++){ if(u[i] != 0){ subtask1 = false; } } if(subtask1){ sort(w.begin(), w.end()); std::vector<long long> ans(n); for(int i = 0; i < n - 1; i++){ ans[n - i - 2] = ans[n - i - 1] + w[i]; } return ans; } bool subtask2 = true; for(int i = 0; i < n - 1; i++){ if(u[i] != i || v[i] != i + 1){ subtask2 = false; } } if(subtask2){ std::vector<long long> ans(n); ans[0] = accumulate(w.begin(), w.end(), 0LL); std::vector<std::vector<long long>> dp(n, std::vector<long long>(2)); for(int i = 0; i < n - 1; i++){ dp[i][0] = (i == 0 ? 0 : min(dp[i - 1][0], dp[i - 1][1])) + w[i]; dp[i][1] = (i == 0 ? 0 : dp[i - 1][0]) + w[i]; } ans[1] = min(dp.back()[0], dp.back()[1]); return ans; } return std::vector<long long>(n, 0); }

컴파일 시 표준 에러 (stderr) 메시지

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:29:32: error: 'min' was not declared in this scope; did you mean 'std::min'?
   29 |       dp[i][0] = (i == 0 ? 0 : min(dp[i - 1][0], dp[i - 1][1])) + w[i];
      |                                ^~~
      |                                std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
roads.cpp:32:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
   32 |     ans[1] = min(dp.back()[0], dp.back()[1]);
      |              ^~~
      |              std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~