제출 #620154

#제출 시각아이디문제언어결과실행 시간메모리
620154rrrr10000선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<P> vp; typedef vector<vp> vvp; typedef vector<bool> vb; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++) #define all(a) a.begin(),a.end() #define lb(v,k) (lower_bound(all(v),k)-v.begin()) #define fi first #define se second #define pb emplace_back template<class T> void out(T a){cout<<a<<endl;} template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;} template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;} const ll inf=1001001001001001001; long long delivery(int N, int K, int L, int p[]) { vi dpl(N),dpr(N); rep(i,N){ dpl[i]=p[i]*2; if(i>=K)dpl[i]+=dpl[i-K]; } for(int i=N-1;i>=0;i--){ dpr[i]=(L-p[i])*2; if(i+K<N)dpr[i]+=dpr[i+K]; } ll ans=min(dpl[N-1],dpr[0]); rep(i,N-1)chmin(ans,dpl[i]+dpr[i+1]); if(N==K)chmin(ans,L); else{ chmin(ans,dpl[N-K-1]+L); chmin(ans,dpr[K]+L); } rep(i,N-K-1)chmin(ans,dpl[i]+dpr[i+K+1]+L); return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:36:24: error: no matching function for call to 'chmin(ll&, int&)'
   36 |     if(N==K)chmin(ans,L);
      |                        ^
boxes.cpp:20:24: note: candidate: 'template<class T> bool chmin(T&, T)'
   20 | template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
      |                        ^~~~~
boxes.cpp:20:24: note:   template argument deduction/substitution failed:
boxes.cpp:36:24: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   36 |     if(N==K)chmin(ans,L);
      |                        ^