Submission #1064363

#TimeUsernameProblemLanguageResultExecution timeMemory
1064363woodHoliday (IOI14_holiday)C++17
Compilation error
0 ms0 KiB
#include"holiday.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define ll long long long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll result = 0; for (int i = 0; i <= start; ++i) { for(int j = start; j<n; j++){ vi res; for(int k = i; k<=j;k++){ res.pb(attractions[k]); } sort(res.begin(),res.end(), greater<>()); int left = d-j+i-1; left = min(d,res.size()); ll sum = 0; for(int k = 0; k<left; k++){ sum+=res[k]; } result = max(result,sum); } } return result; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:13:9: error: 'class std::vector<int>' has no member named 'pb'
   13 |     res.pb(attractions[k]);
      |         ^~
holiday.cpp:13:12: error: 'attractions' was not declared in this scope; did you mean 'attraction'?
   13 |     res.pb(attractions[k]);
      |            ^~~~~~~~~~~
      |            attraction
holiday.cpp:17:27: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
   17 |    left = min(d,res.size());
      |                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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:17:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   17 |    left = min(d,res.size());
      |                           ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 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:17:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   17 |    left = min(d,res.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:17:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |    left = min(d,res.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:17:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |    left = min(d,res.size());
      |                           ^