제출 #586377

#제출 시각아이디문제언어결과실행 시간메모리
586377LastRonin휴가 (IOI14_holiday)C++14
컴파일 에러
0 ms0 KiB
#include"holiday.h" #include <bits/stdc++.h> #define ll long long using namespace std; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll answ = 0; for(int i = 0; i < n; i++) { multiset<ll> a; ll sum = 0; for(int j = i; j < start; j++) a.insert(attraction[j]), sum += attraction[j]; for(int j = start; j < n; j++) { a.insert(attraction[j]); sum += attraction[j]; int enrg = d - min(2 * (j - start) + (start - i), (j - start) + 2 * (start - i)); if(enrg < 0)break; auto it = prev(a.end()); ll cum = 0; enrg = min(enrg, a.size()); while(enrg--) { cum += *it; it = prev(it); } answ = max(answ, cum); } } return answ; } int main() { int n, start, d; int attraction[100000]; int i, n_s; n_s = scanf("%d %d %d", &n, &start, &d); for (i = 0 ; i < n; ++i) { n_s = scanf("%d", &attraction[i]); } printf("%lld\n", findMaxAttraction(n, start, d, attraction)); return 0; } /* 5 2 7 10 2 20 30 1 */

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

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:20:32: error: no matching function for call to 'min(int&, std::multiset<long long int>::size_type)'
   20 |       enrg = min(enrg, a.size());
      |                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from holiday.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
holiday.cpp:20:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::multiset<long long int>::size_type' {aka 'long unsigned int'})
   20 |       enrg = min(enrg, a.size());
      |                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from holiday.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
holiday.cpp:20:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::multiset<long long int>::size_type' {aka 'long unsigned int'})
   20 |       enrg = min(enrg, a.size());
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
holiday.cpp:20:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |       enrg = min(enrg, a.size());
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from holiday.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
holiday.cpp:20:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |       enrg = min(enrg, a.size());
      |                                ^