Submission #1475392


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
for i in range(N):
    if len(Ah[i]) == 1 and len(Th[i]) == 1:
        if Ah[i][0] != Th[i][0]:
            ans = 0   
    elif len(Ah[i]) == 1 and len(Th[i]) == 2:
        if Ah[i][0] > Th[i][1]:
            ans = 0
    elif len(Ah[i]) == 2 and len(Th[i]) == 1:
        if Ah[i][1] < Th[i][0]:
            ans = 0       
    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 960 Byte
Status TLE
Exec Time 2109 ms
Memory 34824 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 3064 KB
0_001.txt AC 17 ms 3064 KB
0_002.txt AC 17 ms 3064 KB
0_003.txt AC 17 ms 3064 KB
1_004.txt AC 17 ms 3064 KB
1_005.txt AC 17 ms 3064 KB
1_006.txt AC 17 ms 3064 KB
1_007.txt AC 17 ms 3064 KB
1_008.txt TLE 2106 ms 32832 KB
1_009.txt AC 223 ms 32728 KB
1_010.txt AC 1051 ms 32748 KB
1_011.txt TLE 2106 ms 32368 KB
1_012.txt AC 304 ms 32320 KB
1_013.txt TLE 2106 ms 32324 KB
1_014.txt AC 357 ms 32812 KB
1_015.txt TLE 2105 ms 34824 KB
1_016.txt AC 591 ms 32356 KB
1_017.txt TLE 2109 ms 33708 KB
1_018.txt AC 757 ms 31812 KB
1_019.txt AC 1126 ms 30328 KB
1_020.txt AC 676 ms 30376 KB