제출 #1123282

#제출 시각아이디문제언어결과실행 시간메모리
1123282heey선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define f first #define s second #define all(x) (x).begin(), (x).end() #define mod 1'000'000'007 #define inf 1'000'000'000'000'00 #define pb push_back #define vvi vector<vi> #define fst ios_base::sync_with_stdio(0);cin.tie(0); using namespace std; #include "boxes.h" long long delivery(int n, int k, int L, int a[]){ int res = INT_MAX; vector<long long> dpc(n+1, 0), dpcc(n+1, 0); for(int i = 1; i <= n; i++){ if(i > k) dpc[i] = dpc[i-k]; dpc[i] += 2*a[i-1]; } for(int i = n-1; i >= 0; i--){ if(i < n-k) dpcc[i] = dpcc[i+k]; dpcc[i] += 2*(L - a[i]); } for(int i = 0; i <= n; i++){ res = min(res, dpc[i] + dpcc[i]); } return res; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:29:26: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   29 |                 res = min(res, dpc[i] + dpcc[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   29 |                 res = min(res, dpc[i] + dpcc[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   29 |                 res = min(res, dpc[i] + dpcc[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                 res = min(res, dpc[i] + dpcc[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
boxes.cpp:29:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                 res = min(res, dpc[i] + dpcc[i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~