답안 #25791

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25791 2017-06-24T07:13:11 Z TAMREF 앱 (KOI13_app) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll D[10005];
int C[105], M[105],N,T;
int main(){
    scanf("%d%d",&N,&T);
    for(int i=0;i<N;i++) scanf("%d",&M[i]);
    for(int i=0;i<N;i++) scanf("%d",&C[i]);
    for(int i=0;i<N;i++){
        for(int c=0;c+C[i]<=1e4;c++){
            if(D[c]) D[c+C[i]]=max(D[c+C[i]],D[c]+M[i]);
        }
        D[C[i]]=max(D[C[i]],M[i]);
    }
    for(int c=0;c<=1e4;c++) if(D[c]>=T) return !printf("%d\n",c);
}

Compilation message

app.cpp: In function 'int main()':
app.cpp:14:33: error: no matching function for call to 'max(ll&, int&)'
         D[C[i]]=max(D[C[i]],M[i]);
                                 ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from app.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
app.cpp:14:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         D[C[i]]=max(D[C[i]],M[i]);
                                 ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from app.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
app.cpp:14:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         D[C[i]]=max(D[C[i]],M[i]);
                                 ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from app.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3457:5: note: candidate: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3457:5: note:   template argument deduction/substitution failed:
app.cpp:14:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         D[C[i]]=max(D[C[i]],M[i]);
                                 ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from app.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463:5: note: candidate: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^
/usr/include/c++/5/bits/stl_algo.h:3463:5: note:   template argument deduction/substitution failed:
app.cpp:14:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         D[C[i]]=max(D[C[i]],M[i]);
                                 ^
app.cpp:7:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&T);
                        ^
app.cpp:8:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<N;i++) scanf("%d",&M[i]);
                                           ^
app.cpp:9:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<N;i++) scanf("%d",&C[i]);
                                           ^