Language: C++

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int a[100001];
	map<int, int> cnt;
	vector<pair<int, int> > tmp;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(cnt.find(a[i]) == cnt.end()){
			cnt[a[i]] = 1;
				tmp.push_back(make_pair(a[i], i));
			}else{
				cnt[a[i]]++;
			}
	}
	sort(tmp.begin(), tmp.end());
	reverse(tmp.begin(), tmp.end());
	long long int checkednum = 0;
	long long int ans[100001] = {};
	tmp.push_back(make_pair(0, 0));
	long long int minindex = n;
	for(int i = 0; i < tmp.size() - 1; i++){
		long long int now = tmp[i].first;
		long long int next = tmp[i + 1].first;
		minindex = min(minindex, tmp[i].second);
		checkednum += cnt[now];
		ans[minindex] += (now - next) * checkednum;
	}
	for(int i = 1; i <= n; i++){
		cout << ans[i] << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:31: error: no matching function for call to 'min(long long int&, int&)'
   48 |                 minindex = min(minindex, tmp[i].second);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:48:31: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   48 |                 minindex = min(minindex, tmp[i].second);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:48:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |                 minindex = min(minindex, tmp[i].second);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~