제출 #1009641

#제출 시각아이디문제언어결과실행 시간메모리
1009641aaaaaarroz모임들 (IOI18_meetings)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<long long> minimum_costs(vector<int> H, vector<int> L,vector<int> R) { int n=H.size(); int Q = L.size(); vector<long long> C(Q); vector<vector<int>>dp(n,vector<int>(n)); for(int i=0;i<n;i++){ int max_height=H[i]; dp[i][i]=max_height; for(int l=i-1;l>=0;l--){ max_height=max(max_height,H[l]); dp[i][l]=(dp[i][l+1]+max_height); } int max_height=H[i]; for(int r=i+1;r<n;r++){ max_height=max(max_height,H[r]); dp[i][r]=(dp[i][r-1]+max_height); } } for(int q=0;q<Q;q++){ C[q]=INT_MAX; for(int i=L[q];i<=R[q];i++){ C[q]=min(C[q],dp[i][L[q]]+dp[i][R[q]]-H[i]); } } return C; }

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

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:15:8: error: redeclaration of 'int max_height'
   15 |    int max_height=H[i];
      |        ^~~~~~~~~~
meetings.cpp:9:8: note: 'int max_height' previously declared here
    9 |    int max_height=H[i];
      |        ^~~~~~~~~~
meetings.cpp:24:47: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   24 |     C[q]=min(C[q],dp[i][L[q]]+dp[i][R[q]]-H[i]);
      |                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from meetings.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
meetings.cpp:24:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   24 |     C[q]=min(C[q],dp[i][L[q]]+dp[i][R[q]]-H[i]);
      |                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from meetings.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
meetings.cpp:24:47: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   24 |     C[q]=min(C[q],dp[i][L[q]]+dp[i][R[q]]-H[i]);
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
meetings.cpp:24:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |     C[q]=min(C[q],dp[i][L[q]]+dp[i][R[q]]-H[i]);
      |                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
meetings.cpp:24:47: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |     C[q]=min(C[q],dp[i][L[q]]+dp[i][R[q]]-H[i]);
      |                                               ^