結果

問題 No.1765 While Shining
ユーザー MasKoaTSMasKoaTS
提出日時 2022-01-05 22:58:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 116,820 KB
最終ジャッジ日時 2024-04-24 03:35:23
合計ジャッジ時間 5,329 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
86,724 KB
testcase_01 AC 125 ms
86,976 KB
testcase_02 AC 129 ms
86,656 KB
testcase_03 AC 131 ms
86,656 KB
testcase_04 AC 129 ms
86,804 KB
testcase_05 AC 130 ms
86,832 KB
testcase_06 AC 136 ms
86,828 KB
testcase_07 AC 133 ms
86,728 KB
testcase_08 AC 134 ms
86,656 KB
testcase_09 AC 162 ms
105,180 KB
testcase_10 AC 174 ms
116,224 KB
testcase_11 AC 168 ms
110,380 KB
testcase_12 AC 173 ms
113,300 KB
testcase_13 AC 166 ms
110,084 KB
testcase_14 AC 177 ms
116,632 KB
testcase_15 AC 177 ms
116,264 KB
testcase_16 AC 175 ms
116,756 KB
testcase_17 AC 175 ms
116,608 KB
testcase_18 AC 173 ms
116,736 KB
testcase_19 AC 173 ms
116,704 KB
testcase_20 AC 172 ms
116,820 KB
testcase_21 AC 171 ms
116,640 KB
testcase_22 AC 174 ms
116,400 KB
testcase_23 AC 175 ms
116,608 KB
testcase_24 AC 167 ms
116,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from copy import deepcopy as dcopy
import math
import sys
sys.setrecursionlimit(10**6)
def input():
    return sys.stdin.readline().rstrip()
def getN():
	return int(sys.stdin.readline())
def getNs():
	return map(int,sys.stdin.readline().split())
def getList():
	return list(map(int,sys.stdin.readline().split()))
def strinps(n):
	return [sys.stdin.readline().rstrip() for _ in range(n)]
pi = 3.141592653589793
mod = 10**9+7
MOD = 998244353
INF = math.inf
dx = [1,0,-1,0];	dy = [0,1,0,-1]


"""
Main Code
"""

n = getN()
a = getList()

ans = p = q = 0
for i in range(n - 1):
	t = i & 1
	#even
	if(a[i] ^ t):
		if not(t):
			p += 1
		ans += p
	else:
		p = 0
	#odd
	if not(a[i] ^ t):
		if(t):
			q += 1
		ans += q
	else:
		q = 0
print(ans)
0