結果
| 問題 |
No.1505 Zero-Product Ranges
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-13 13:27:53 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 477 bytes |
| コンパイル時間 | 129 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 14,716 KB |
| 最終ジャッジ日時 | 2024-11-07 09:06:14 |
| 合計ジャッジ時間 | 5,659 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
def main():
N = int(input())
A = list(map(int, input().split()))
all_patterns = N * (N+1) // 2
current_length = 0
patterns_1 = 0
for A_elm in A:
if A_elm == 1:
current_length += 1
else:
patterns_1 += current_length * (current_length + 1) // 2
current_length = 0
patterns_1 += current_length * (current_length + 1) // 2
print(all_patterns - patterns_1)
if __name__ == "__main__":
main()