結果

問題 No.921 ずんだアロー
ユーザー mkawa2mkawa2
提出日時 2021-03-25 13:48:02
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 17,636 KB
最終ジャッジ日時 2023-08-18 00:53:38
合計ジャッジ時間 2,905 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,200 KB
testcase_01 AC 15 ms
8,208 KB
testcase_02 AC 16 ms
8,348 KB
testcase_03 AC 15 ms
8,240 KB
testcase_04 AC 16 ms
8,296 KB
testcase_05 AC 15 ms
8,280 KB
testcase_06 AC 16 ms
8,188 KB
testcase_07 AC 16 ms
8,240 KB
testcase_08 AC 16 ms
7,932 KB
testcase_09 AC 16 ms
7,856 KB
testcase_10 AC 71 ms
16,540 KB
testcase_11 AC 75 ms
17,148 KB
testcase_12 AC 29 ms
10,208 KB
testcase_13 AC 58 ms
14,512 KB
testcase_14 AC 63 ms
15,656 KB
testcase_15 AC 44 ms
12,804 KB
testcase_16 AC 20 ms
8,828 KB
testcase_17 AC 66 ms
15,836 KB
testcase_18 AC 69 ms
17,576 KB
testcase_19 AC 70 ms
17,636 KB
testcase_20 AC 70 ms
17,620 KB
testcase_21 AC 70 ms
17,484 KB
testcase_22 AC 69 ms
17,452 KB
testcase_23 AC 78 ms
17,576 KB
testcase_24 AC 69 ms
17,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

n=II()
aa=LI()
cc=[1]
for i in range(1,n):
    if aa[i-1]==aa[i]:
        cc[-1]+=1
    else:
        cc.append(1)

ans=0
mochi=True
for c in cc:
    if mochi:
        ans+=c
        mochi=False
    else:
        if c==1:
            mochi=True
        else:
            ans+=c-1

print(ans)
0