Language: C++

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<ll> t(n), a(n);
	for (int i = 0; i < n; i++) cin >> t[i];
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<P> v(n, P(INF,0)); // max min;
	v[0] = P(t[0], t[0]);
	v[n - 1] = P(a[n - 1], a[n - 1]);
	bool flag = false;
	for (int i = 1; i < n; i++) {
		if (t[i] != t[i - 1]) {
			if (t[i] > v[i].first || v[i].second > t[i]) {
				flag = true;
				break;
			}
			else {
				v[i] = P(t[i], t[i]);
			}
		}
		else {
			ll ma = min(v[i].first, t[i]);
			ll mi = max(v[i].second, (ll)1);
			v[i] = P(ma, mi);
		}
	}
	if (flag) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] != a[i + 1]) {
			if (a[i] > v[i].first || v[i].second > a[i]) {
				flag = true;
				break;
			}
			else {
				v[i] = P(a[i], a[i]);
			}
		}
		else {
			int ma = min(v[i].first, a[i]);
			int mi = max(v[i].second, 1);
			v[i] = P(ma, mi);
		}
	}
	if (flag) {
		cout << 0 << endl;
		return 0;
	}
	ll res = 1;
	for (int i = 0; i < n; i++) {
		if (v[i].first < v[i].second) {
			cout << 0 << endl;
			return 0;
		}
		res = res*(v[i].first - v[i].second + 1);
		res %= MOD;
	}
	cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:37: error: no matching function for call to 'max(long long int&, int)'
   55 |                         int mi = max(v[i].second, 1);
      |                                  ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:55:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   55 |                         int mi = max(v[i].second, 1);
      |                                  ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:55:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   55 |                         int mi = max(v[i].second, 1);
      |                                  ~~~^~~~~~~~~~~~~~~~