답안 #362928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362928 2021-02-04T18:18:55 Z David_M 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std;
long long delivery(int n,int k,int L,int p[]){
long long i,Ans=1e18,l[n+1],r[n+1];l[0]=r[0]=0;
for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
for(i=0;i<=n;i++)Ans=min(Ans,l[i]+min(r[n-i],r[max(n-i-k,0)]+L));
return Ans;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:6:34: error: no matching function for call to 'max(long long int, int)'
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                  ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                  ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                  ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                  ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                  ^
boxes.cpp:6:62: error: no matching function for call to 'max(long long int, int)'
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
boxes.cpp:6:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    6 | for(i=1;i<=n;i++)r[i]=r[max(i-k,0)]+p[i-1]*2,l[i]=l[max(i-k,0)]+(L-p[n-i])*2;
      |                                                              ^
boxes.cpp:7:59: error: no matching function for call to 'max(long long int, int)'
    7 | for(i=0;i<=n;i++)Ans=min(Ans,l[i]+min(r[n-i],r[max(n-i-k,0)]+L));
      |                                                           ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
boxes.cpp:7:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    7 | for(i=0;i<=n;i++)Ans=min(Ans,l[i]+min(r[n-i],r[max(n-i-k,0)]+L));
      |                                                           ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
boxes.cpp:7:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
    7 | for(i=0;i<=n;i++)Ans=min(Ans,l[i]+min(r[n-i],r[max(n-i-k,0)]+L));
      |                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:7:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    7 | for(i=0;i<=n;i++)Ans=min(Ans,l[i]+min(r[n-i],r[max(n-i-k,0)]+L));
      |                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
boxes.cpp:7:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    7 | for(i=0;i<=n;i++)Ans=min(Ans,l[i]+min(r[n-i],r[max(n-i-k,0)]+L));
      |                                                           ^