85432024-01-21 16:55:01zeytonxBányász RPG (40 pont)cpp17Compilation error
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pll pair<long, long>
#define endl "\n"
#define fs first
#define sc second
#define vll vector<ll>

void solve()
{
	ll n;
	cin >> n;
	map<ll,ll> m;
	vll a(n);
	ll remain = 0, ans = 0, exp = 0;
	for(ll i = 0; i < n; i++)
		cin >> a[i];
	for(ll i = 0; i < n; i++)
	{
		ll inp;
		cin >> inp;
		remain += inp;
		m[a[i]] += inp;
	}
	vector<pll> v;
	for(auto i : m)
		v.push_back({i.sc, i.fs});

	auto max_it = m.begin();
	ll max_v = -1;

	while(remain > 0)
	{
		for(auto it = m.begin(); it != m.end(); it++)
		{
			if((*it).sc == 0)
				continue;
			if((*it).fs > exp)
				break;
			ans += (*it).sc;
			remain -= (*it).sc;
			exp += (*it).sc;
			(*it).sc = 0;
		}

		if((*max_it) != max_v-1)
		for(auto it = m.begin(); it != m.end(); it++)
		{
			if((*it).sc > max_v)
			{
				max_v = (*it).sc;
				max_it = it;
			}
		}

		if((*max_it).sc > 0)
		{
			(*max_it).sc--;
			ans += 2;
			remain -= 1;
			exp++;
		}
	}
	cout << ans << endl;
}

int main() 
{
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	ll t = 1;
	//cin >> t;
	while(t--) solve();
	return 0;
}
Compilation error
exit status 1
main.cpp: In function 'void solve()':
main.cpp:49:30: error: no match for 'operator!=' (operand types are 'std::pair<const long long int, long long int>' and 'long long int')
   49 |                 if((*max_it) != max_v-1)
      |                    ~~~~~~~~~ ^~ ~~~~~~~
      |                     |                |
      |                     |                long long int
      |                     std::pair<const long long int, long long int>
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from main.cpp:1:
/usr/include/c++/11/bits/regex.h:1088:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)'
 1088 |     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/11/bits/regex.h:1088:5: note:   template argument deduction/substitution failed:
mai...