Submission #1475395


Source Code Expand

N = int(input())

T = list(map(int, input().split()))
A = list(map(int, input().split()))


Th = [[T[0]]]
th_prev = T[0]
for i in range(1, N):
    if T[i] == th_prev:
        Th.append([1, th_prev])
    else:
        Th.append([T[i]])
        th_prev = T[i]

A = A[::-1]
Ah = [[A[0]]]
ah_prev = A[0]
for i in range(1, N):
    if A[i] == ah_prev:
        Ah.append([1, ah_prev])
    else:
        Ah.append([A[i]])
        ah_prev = A[i]
        
Ah = Ah[::-1]
ans = 1
ansable = True
for i in range(N):
    if ansable == False:
        break
    
    elif len(Ah[i]) == 1 and len(Th[i]) == 1:
        if Ah[i][0] != Th[i][0]:
            ans = 0   
            ansable = False
    elif len(Ah[i]) == 1 and len(Th[i]) == 2:
        if Ah[i][0] > Th[i][1]:
            ans = 0
            ansable = False
    elif len(Ah[i]) == 2 and len(Th[i]) == 1:
        if Ah[i][1] < Th[i][0]:
            ans = 0  
            ansable = False
    elif len(Ah[i]) == 2 and len(Th[i]) == 2:
         ans *= (min(Ah[i][1],Th[i][1]))%(10**9+7)
            
print(ans%(10**9+7))

Submission Info

Submission Time
Task C - Two Alpinists
User TakuyaNakazato02
Language Python (3.4.3)
Score 0
Code Size 1107 Byte
Status TLE
Exec Time 2105 ms
Memory 32832 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 4
AC × 16
TLE × 5
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 17 ms 3188 KB
0_001.txt AC 17 ms 3188 KB
0_002.txt AC 17 ms 3188 KB
0_003.txt AC 17 ms 3188 KB
1_004.txt AC 17 ms 3188 KB
1_005.txt AC 17 ms 3188 KB
1_006.txt AC 17 ms 3188 KB
1_007.txt AC 17 ms 3188 KB
1_008.txt TLE 2105 ms 32448 KB
1_009.txt AC 222 ms 32724 KB
1_010.txt AC 1038 ms 32364 KB
1_011.txt TLE 2105 ms 32368 KB
1_012.txt AC 227 ms 32832 KB
1_013.txt TLE 2105 ms 32324 KB
1_014.txt AC 260 ms 32428 KB
1_015.txt TLE 2105 ms 32356 KB
1_016.txt AC 505 ms 32412 KB
1_017.txt TLE 2105 ms 32004 KB
1_018.txt AC 710 ms 31428 KB
1_019.txt AC 1128 ms 29944 KB
1_020.txt AC 621 ms 30372 KB