結果
| 問題 | 
                            No.921 ずんだアロー
                             | 
                    
| コンテスト | |
| ユーザー | 
                             simamumu
                         | 
                    
| 提出日時 | 2019-11-08 21:37:13 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 762 bytes | 
| コンパイル時間 | 101 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 21,972 KB | 
| 最終ジャッジ日時 | 2024-09-15 01:17:20 | 
| 合計ジャッジ時間 | 3,494 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 1 | 
ソースコード
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
N = inp()
AA = inpl()
tmpl = []
ba = -1
for a in AA:
    if ba == a:
        tmpl[-1] += 1
    else:
        tmpl.append(1)
    ba = a
L = len(tmpl)
# print(tmpl)
DP = [0]*L
if L == 1:
    print(tmpl[0])
elif L == 2:
    print(sum(tmpl)-1)
for i,x in enumerate(tmpl):
    if i == 0:
        DP[i] = x
    else:
        DP[i] = max(DP[i-1] + x-1, DP[i-2] + x + max(0,tmpl[i-1]-2))
# print(DP)
print(DP[-1])
            
            
            
        
            
simamumu