제출 #1348984

#제출 시각아이디문제언어결과실행 시간메모리
1348984enzy선물상자 (IOI15_boxes)C++20
컴파일 에러
0 ms0 KiB
#include "boxes.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf=1e18;

ll delivery(int N, int K, int L, int p[]){
    vector<int>v;
    for(int i=0;i<N;i++) if(p[i]) v.push_back(p[i]);
    sort(v.begin(),v.end());
    if(v.empty()) return 0;
    int n=v.size();
    vector<ll>pref(n), suf(n);
    for(int i=0;i<n;i++){
        if(i>=K) pref[i]=pref[i-K];
        pref[i]+=2*v[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i+K<n) suf[i]=suf[i+K];
        suf[i]+=2*(L-v[i]);
    }
    ll resp=min(suf[0],pref.back());
    if(K>n) resp=min(resp,L);
    for(int i=0;i+K-1<n;i++){
        ll at=0;
        if(i-1>=0) at+=pref[i-1];
        if(i+K<n) at+=suf[i+K];
        resp=min(resp,at+L);
    }
    for(int i=0;i+1<n;i++) resp=min(resp,pref[i]+suf[i+1]);
    return resp;
}

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:23:21: error: no matching function for call to 'min(long long int&, int&)'
   23 |     if(K>n) resp=min(resp,L);
      |                  ~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from boxes.cpp:2:
/usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
boxes.cpp:23:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |     if(K>n) resp=min(resp,L);
      |                  ~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:281:5: note:   template argument deduction/substitution failed:
boxes.cpp:23:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |     if(K>n) resp=min(resp,L);
      |                  ~~~^~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5775 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5775:5: note:   template argument deduction/substitution failed:
boxes.cpp:23:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |     if(K>n) resp=min(resp,L);
      |                  ~~~^~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5785:5: note:   template argument deduction/substitution failed:
boxes.cpp:23:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |     if(K>n) resp=min(resp,L);
      |                  ~~~^~~~~~~~