Language: C++


#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 998244353;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};


ll N, x;
vector<ll> a;
ll vis[2000];
int main() {
	
	cin >> N >> x;
	a.resize(N);
	ll mi = inf;
	rep(i, N) {
		cin >> a[i];

		mi = min(a[i], mi);

	}
	

	ll sum = 0;
	rep(i, N) {
		if (a[i] == mi) {
			sum += mi;
			vis[i] = 1;
		}
	}

	bool flag = true;
	ll index = 0;
	vector<ll> q;
	while (flag == true) {
		flag = false;

		for (index = 0; index < N; index++) {
			if (index > 0 && vis[index] == 0 && vis[index - 1] == 1) {
				q.push_back(index);
				flag = true;
			}

			else if (index == 0 && vis[index] == 0 && vis[N - 1] == 1) {
				q.push_back(index);
				flag = true;
			}
		}

		ll s = 0;

		rep(i, q.size()) {
			s += a[q[i]];
			vis[q[i]] = 1;
		}

		sum += min(s, x + mi * q.size());

		while (!q.empty()) { q.pop_back(); }

	}


	cout << sum << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:27: error: no matching function for call to 'min(ll&, long long unsigned int)'
   76 |                 sum += min(s, x + mi * q.size());
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/queue:62,
                 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:76:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   76 |                 sum += min(s, x + mi * q.size());
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:76:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   76 |                 sum += min(s, x + mi * q.size());
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~~