結果

問題 No.921 ずんだアロー
ユーザー hedwig100hedwig100
提出日時 2020-04-10 13:56:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 1,190 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 24,580 KB
最終ジャッジ日時 2023-10-13 02:43:43
合計ジャッジ時間 3,516 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,692 KB
testcase_01 AC 19 ms
8,692 KB
testcase_02 AC 19 ms
8,688 KB
testcase_03 AC 19 ms
8,708 KB
testcase_04 AC 19 ms
8,528 KB
testcase_05 AC 19 ms
8,556 KB
testcase_06 AC 19 ms
8,556 KB
testcase_07 AC 20 ms
8,692 KB
testcase_08 AC 19 ms
8,560 KB
testcase_09 AC 19 ms
8,528 KB
testcase_10 AC 99 ms
22,528 KB
testcase_11 AC 105 ms
24,372 KB
testcase_12 AC 36 ms
11,780 KB
testcase_13 AC 75 ms
19,852 KB
testcase_14 AC 83 ms
20,828 KB
testcase_15 AC 56 ms
16,196 KB
testcase_16 AC 24 ms
9,688 KB
testcase_17 AC 85 ms
21,248 KB
testcase_18 AC 107 ms
24,184 KB
testcase_19 AC 107 ms
24,128 KB
testcase_20 AC 106 ms
24,224 KB
testcase_21 AC 106 ms
24,100 KB
testcase_22 AC 107 ms
24,140 KB
testcase_23 AC 106 ms
24,580 KB
testcase_24 AC 107 ms
24,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop

def main():
    n = int(input())
    a = list(map(int,input().split())) + [-1]

    dp = [[0] * 2 for _ in range(n)]
    
    dp[0][0] = 0
    dp[0][1] = 1
    for i in range(1,n):
        if a[i] == a[i - 1]:
            dp[i][1] = dp[i - 1][1] + 1
            dp[i][0] = dp[i - 1][1]
        else:
            dp[i][1] = dp[i - 1][0] + 1
            dp[i][0] = dp[i - 1][1]
    
    print(max(dp[-1]))

if __name__ =='__main__':
    main()  
0