80982024-01-12 13:07:40David9320Hús sütés (75 pont)cpp17Compilation error
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;

    vector<int> husik(n);

    for(int i = 0; i < n; i++) {
        cin >> husik[i];
    }

    sort(husik.rbegin, husik.rend());

    int maximum = 0;
    for(int i = 0; i < n; i++) {
        if(maximum < husik[i] + i - 1) {
            maximum = husik[i] + i - 1;
        }
    }

    cout << maximum;

    return 0;
}
Compilation error
exit status 1
main.cpp: In function 'int main()':
main.cpp:18:9: error: no matching function for call to 'sort(<unresolved overloaded function type>, std::vector<int>::reverse_iterator)'
   18 |     sort(husik.rbegin, husik.rend());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from main.cpp:3:
/usr/include/c++/11/bits/stl_algo.h:4832:5: note: candidate: 'void std::sort(_RAIter, _RAIter) [with _RAIter = std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >]'
 4832 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/11/bits/stl_algo.h:4832:32: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'
 4832 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/11/bits/stl_algo.h:4863:5...