Submission #948214


Source Code Expand

#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <time.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define mod 1000000009
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)

int main()
{
    int n;
    long long t[100010],a[100010];
    long long kaku[100010];
    long long ans = 1;
    int flag = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        kaku[i] = -1;
    }
    for(int i = 0;i < n;i++){
        cin >> t[i];
        if(i == 0){
            kaku[i] = t[i];
        }
    }
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(i == n - 1){
            kaku[n - 1] = a[i];
        }
    }
    for(int i = 0;i < n; i++){
        if((t[n - 1] != a[0]) || (t[n - 1] < a[n - 1]) || (t[0] > a[0])){
            ans = 0;
            break;
        }
        if(kaku[i] == -1){
            if(t[i] - t[i - 1] != 0 && a[i] - a[i + 1] != 0){
                if(t[i] == a[i])kaku[i] = t[i];
                else ans = 0;
            }else if(t[i] - t[i - 1] != 0 && a[i] - a[i + 1] == 0){
                if(t[i] <= a[i])kaku[i] = t[i];
                else ans = 0;
            }else if(t[i] - t[i - 1] == 0 && a[i] - a[i + 1] != 0){
                if(a[i] <= t[i])kaku[i] = a[i];
                else ans = 0;
            }
        }
    }
    if(ans == 1){
        for(int i = 1;i < n - 1;i++){     
            if(kaku[i] == -1){
                if(t[i] <= a[i]){
                    ans *= t[i];
                }else if(t[i] > a[i]){
                    ans *= a[i];
                }
            }
           ans %= 1000000007; 
        }
        
    }
        
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Two Alpinists
User hanada009
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2103 Byte
Status AC
Exec Time 148 ms
Memory 2560 KiB

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 3 ms 256 KiB
0_001.txt AC 3 ms 256 KiB
0_002.txt AC 3 ms 256 KiB
0_003.txt AC 3 ms 256 KiB
1_004.txt AC 3 ms 256 KiB
1_005.txt AC 3 ms 256 KiB
1_006.txt AC 3 ms 256 KiB
1_007.txt AC 3 ms 256 KiB
1_008.txt AC 148 ms 2560 KiB
1_009.txt AC 117 ms 2560 KiB
1_010.txt AC 126 ms 2560 KiB
1_011.txt AC 134 ms 2560 KiB
1_012.txt AC 128 ms 2560 KiB
1_013.txt AC 134 ms 2560 KiB
1_014.txt AC 129 ms 2560 KiB
1_015.txt AC 135 ms 2560 KiB
1_016.txt AC 130 ms 2560 KiB
1_017.txt AC 124 ms 2560 KiB
1_018.txt AC 115 ms 2560 KiB
1_019.txt AC 99 ms 2560 KiB
1_020.txt AC 94 ms 2560 KiB