結果
問題 | No.921 ずんだアロー |
ユーザー | simamumu |
提出日時 | 2019-11-08 21:38:19 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 182 ms / 2,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 775 ms |
コンパイル使用メモリ | 10,956 KB |
実行使用メモリ | 21,540 KB |
最終ジャッジ日時 | 2023-10-13 03:38:41 |
合計ジャッジ時間 | 4,075 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,108 KB |
testcase_01 | AC | 31 ms
10,136 KB |
testcase_02 | AC | 30 ms
9,952 KB |
testcase_03 | AC | 30 ms
9,948 KB |
testcase_04 | AC | 31 ms
9,944 KB |
testcase_05 | AC | 31 ms
10,136 KB |
testcase_06 | AC | 31 ms
10,120 KB |
testcase_07 | AC | 31 ms
9,952 KB |
testcase_08 | AC | 31 ms
10,100 KB |
testcase_09 | AC | 31 ms
9,952 KB |
testcase_10 | AC | 167 ms
19,820 KB |
testcase_11 | AC | 181 ms
21,108 KB |
testcase_12 | AC | 63 ms
12,312 KB |
testcase_13 | AC | 138 ms
17,932 KB |
testcase_14 | AC | 150 ms
18,612 KB |
testcase_15 | AC | 104 ms
16,444 KB |
testcase_16 | AC | 41 ms
10,788 KB |
testcase_17 | AC | 156 ms
19,348 KB |
testcase_18 | AC | 82 ms
20,852 KB |
testcase_19 | AC | 81 ms
20,864 KB |
testcase_20 | AC | 83 ms
20,804 KB |
testcase_21 | AC | 81 ms
20,804 KB |
testcase_22 | AC | 81 ms
20,984 KB |
testcase_23 | AC | 182 ms
21,540 KB |
testcase_24 | AC | 83 ms
20,812 KB |
ソースコード
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]) sys.exit() elif L == 2: print(sum(tmpl)-1) sys.exit() 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])