Language: C++

#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>


using namespace std;


int main(){
	vector<long> memory;
	vector<long> vec;
	int N;
	cin >> N;
	long old;
	long a;
	for(int i=0;i<N;i++){

		cin >> a;
		vec.push_back(a);
	}

	int color_num=0;
	while(vec.size()!=0){

		vector<int>::iterator max_iter = max_element(vec.begin(), vec.end());

		int index = distance(vec.begin(), max_iter);
		int count=0;
		while(count<index && index!=0){
			if(vec[count]<vec[index]){
				vec.erase(vec.begin()+index-count);	

				break;
			}	
		count++;
		}
		vec.erase(index);
		color_num++;
	}
	cout << color_num << endl;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:61: error: conversion from '__normal_iterator<long int*,vector<long int>>' to non-scalar type '__normal_iterator<int*,vector<int>>' requested
   26 |                 vector<int>::iterator max_iter = max_element(vec.begin(), vec.end());
      |                                                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:28:37: error: no matching function for call to 'distance(std::vector<long int>::iterator, std::vector<int>::iterator&)'
   28 |                 int index = distance(vec.begin(), max_iter);
      |                             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note: candidate: 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note:   template argument deduction/substitution failed:
a.cc:28:37: note:   deduced conflicting types for parameter '_InputIterator' ('__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   28 |                 int index = distance(vec.begin(), max_iter);
      |                             ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
a.cc:38:26: error: no matching function for call to 'std::vector<long int>::erase(int&)'
   38 |                 vec.erase(index);
      |                 ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1536:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator) [with _Tp = long int; _Alloc = std::allocator<long int>; iterator = std::vector<long int>::iterator; const_iterator = std::vector<long int>::const_iterator]'
 1536 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1536:28: note:   no known conversion for argument 1 from 'int' to 'std::vector<long int>::const_iterator'
 1536 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::erase(const_iterator, const_iterator) [with _Tp = long int; _Alloc = std::allocator<long int>; iterator = std::vector<long int>::iterator; const_iterator = std::vector<long int>::const_iterator]'
 1564 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_vector.h:1564:7: note:   candidate expects 2 arguments, 1 provided