結果

問題 No.921 ずんだアロー
ユーザー c0degeekc0degeek
提出日時 2019-11-08 22:50:27
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 16,440 KB
最終ジャッジ日時 2023-10-13 04:27:48
合計ジャッジ時間 2,438 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,804 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 15 ms
7,780 KB
testcase_03 AC 16 ms
7,756 KB
testcase_04 AC 16 ms
7,760 KB
testcase_05 AC 16 ms
7,920 KB
testcase_06 AC 16 ms
7,784 KB
testcase_07 AC 15 ms
7,904 KB
testcase_08 AC 16 ms
7,784 KB
testcase_09 AC 16 ms
7,748 KB
testcase_10 AC 95 ms
15,904 KB
testcase_11 AC 95 ms
16,400 KB
testcase_12 AC 34 ms
9,840 KB
testcase_13 AC 73 ms
14,036 KB
testcase_14 AC 83 ms
14,760 KB
testcase_15 AC 55 ms
11,972 KB
testcase_16 AC 21 ms
8,752 KB
testcase_17 AC 87 ms
14,852 KB
testcase_18 AC 56 ms
15,684 KB
testcase_19 AC 54 ms
15,644 KB
testcase_20 AC 54 ms
15,668 KB
testcase_21 AC 53 ms
15,792 KB
testcase_22 AC 54 ms
15,852 KB
testcase_23 AC 101 ms
16,440 KB
testcase_24 AC 53 ms
15,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
l=input().split()
a=[]
j,num=1,0
for i in range(n-1):
    if l[i]==l[i+1]:
        j+=1
    else:
        a.append(j)
        j=1
        num+=1
a.append(j)
num+=1
s=a[0]
m=0
for i in range(num-1):
    x,y=a[i],a[i+1]
    if x==1:
        if m==1:
            s+=y
            m=0
        elif y==1:
            m=1
        else:
            s+=y-1
    elif y==1:
        m=1
    else:
        s+=y-1
print(s)
0