結果

問題 No.1334 Multiply or Add
ユーザー tobusakana
提出日時 2023-09-07 20:44:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,204 KB
実行使用メモリ 107,984 KB
最終ジャッジ日時 2024-06-25 14:26:17
合計ジャッジ時間 9,498 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 37 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

# はじにある1は足したほうがよい
N = int(input())
A = list(map(int,input().split()))

from collections import deque
q = deque(A)
DIV = 10 ** 9 + 7

ans = 0
while q:
    found = False
    if q[0] == 1:
        ans += 1
        q.popleft()
        found = True
    elif q[-1] == 1:
        ans += 1
        q.pop()
        found = True
    if not found:
        break
    
def f(X):
    res = 1
    for x in X:
        res *= x
        res %= DIV
    return res
    
print((ans + f(q)) % DIV)
0