結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
👑 |
提出日時 | 2021-08-05 13:56:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 243 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 98,436 KB |
最終ジャッジ日時 | 2024-09-16 15:20:34 |
合計ジャッジ時間 | 4,607 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
n = int(input()) alst = list(map(int, input().split())) ans = n * (n + 1) // 2 cnt = 0 for a in alst: if a == 1: cnt += 1 else: ans -= cnt * (cnt + 1) // 2 cnt = 0 ans -= cnt * (cnt + 1) // 2 print(ans)