結果

問題 No.921 ずんだアロー
ユーザー paruf4paruf4
提出日時 2020-06-24 00:21:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 411 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 19,800 KB
最終ジャッジ日時 2023-09-16 20:21:07
合計ジャッジ時間 2,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,116 KB
testcase_01 AC 16 ms
8,272 KB
testcase_02 AC 16 ms
8,216 KB
testcase_03 AC 16 ms
8,092 KB
testcase_04 RE -
testcase_05 AC 16 ms
8,080 KB
testcase_06 AC 17 ms
8,204 KB
testcase_07 AC 17 ms
8,128 KB
testcase_08 AC 16 ms
8,168 KB
testcase_09 AC 16 ms
8,216 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 42 ms
10,524 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 73 ms
13,256 KB
testcase_16 AC 24 ms
8,880 KB
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 137 ms
19,532 KB
testcase_24 AC 52 ms
19,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
if n==1:
  print(1)
  exit(0)

from itertools import groupby
gr=groupby(a)
l=[]
for k,g in gr:
  l.append(len(list(g)))
ans=0
t=0
m=[]
for i in range(len(l)):
  if l[i]>1:
    ans+=l[i]
    m.append(t)
    t=0
  else:
    if i>0 and l[i-1]>1:continue
    if i<n-1 and l[i+1]>1:continue
    t+=1
if t!=0:
  m.append(t)
for mm in m:
  ans+=(mm+2-1)//2
print(ans)


0