Submission #1455401


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

const int MOD=1e9+7;
signed main() {
    int n;
    cin>>n;
    vector<int> T(n),A(n),M(n);
    vector<bool> ch1(n,false),ch2(n,false);
    cin>>T>>A;

    REP(i,n) {
        M[i]=min(T[i],A[i]);
    }
    ch1[0]=true;
    REPF(i,1,n) {
        if(T[i-1]<T[i]) ch1[i]=true;
    }
    ch2[n-1]=true;
    for(int i=n-2;i>=0;i--) {
        if(A[i]>A[i+1]) ch2[i]=true;
    }

    REP(i,n) {
        if((ch1[i] && T[i]>A[i]) || (ch2[i] && T[i]<A[i])) {
            cout<<0<<endl;
            return 0;
        }
    }

    int ans=1;
    REP(i,n) {
        if(!ch1[i] && !ch2[i]) {
            ans*=M[i];
            ans%=MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - Two Alpinists
User algon
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2451 Byte
Status AC
Exec Time 23 ms
Memory 2688 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 21
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
0_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 23 ms 2688 KB
1_009.txt AC 20 ms 2688 KB
1_010.txt AC 21 ms 2688 KB
1_011.txt AC 22 ms 2688 KB
1_012.txt AC 21 ms 2688 KB
1_013.txt AC 22 ms 2688 KB
1_014.txt AC 21 ms 2688 KB
1_015.txt AC 22 ms 2688 KB
1_016.txt AC 21 ms 2688 KB
1_017.txt AC 21 ms 2688 KB
1_018.txt AC 20 ms 2688 KB
1_019.txt AC 19 ms 2688 KB
1_020.txt AC 18 ms 2688 KB