Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ld long double
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  ll t[n];
  ll a[n];
  rep(i,n)cin >> t[i];
  rep(i,n)cin >> a[i];
  ll mi[n];
  ll ma[n];
  mi[0]=t[0];
  ma[0]=t[0];
  if(t[n-1]!=a[0]){
    cout << 0 << endl;
    return 0;
  }
  rep(i,n-1){
    if(t[i]==t[i+1]){
      mi[i+1]=1;
      ma[i+1]=t[i];
    }
    else{
      mi[i+1]=t[i+1];
      ma[i+1]=t[i+1];
    }
  }
  ll ans=1;
  ll p=1000000007;
  rep(i,n-1){
    int y=n-1-i;
    ll mii,maa;
    if(a[y]==a[y-1]){
      mii=1;
      maa=a[y];
    }
    else{
      mii=a[y-1];
      maa=a[y-1];
    }
    if(mii>ma[y-1]||mi[y-1]>maa){
      cout << 0 << endl;
      return 0;
    }
    else{
      ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
      //cout << y-1 <<  " " <<  ans << endl;
    }
  }
  cout << ans << endl;
  /*ll m=8848;
  ll z=3776;
  cout << m*m*m%p*z%p << endl;*/
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:19: error: no matching function for call to 'max(int, long long int)'
   54 |       ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:54:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   54 |       ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:54:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   54 |       ans=(ans*max(0,(1+min(min(ma[y-1]-mii,maa-mi[y-1]),min(maa-mii,ma[y-1]-mi[y-1])))))%p;
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~