結果

問題 No.921 ずんだアロー
ユーザー __salty_life__salty_life
提出日時 2019-11-08 23:29:08
言語 Ruby
(3.3.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 267 bytes
コンパイル時間 1,051 ms
コンパイル使用メモリ 11,496 KB
実行使用メモリ 26,496 KB
最終ジャッジ日時 2023-10-13 05:09:05
合計ジャッジ時間 6,294 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,272 KB
testcase_01 AC 80 ms
15,152 KB
testcase_02 AC 81 ms
15,264 KB
testcase_03 AC 80 ms
15,232 KB
testcase_04 AC 80 ms
15,132 KB
testcase_05 AC 81 ms
15,084 KB
testcase_06 AC 80 ms
15,172 KB
testcase_07 AC 81 ms
15,252 KB
testcase_08 AC 79 ms
15,120 KB
testcase_09 AC 81 ms
15,188 KB
testcase_10 AC 162 ms
21,032 KB
testcase_11 AC 175 ms
25,952 KB
testcase_12 AC 98 ms
16,668 KB
testcase_13 AC 146 ms
20,700 KB
testcase_14 AC 153 ms
20,684 KB
testcase_15 AC 127 ms
20,320 KB
testcase_16 AC 86 ms
15,628 KB
testcase_17 AC 156 ms
20,880 KB
testcase_18 AC 179 ms
26,460 KB
testcase_19 AC 179 ms
26,312 KB
testcase_20 AC 179 ms
26,472 KB
testcase_21 AC 180 ms
26,360 KB
testcase_22 AC 182 ms
26,412 KB
testcase_23 AC 181 ms
26,476 KB
testcase_24 AC 180 ms
26,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #


N=gets.to_i
A=gets.split.map(&:to_i)

dp=Array.new(N+1){Array.new(2,0)} #not zunda,zunda
dp[0][0]=0
N.times do |i|
  dp[i+1][0]=dp[i].max
  if i!=0 && A[i]!=A[i-1]
    dp[i+1][1]=[dp[i][0]+1,dp[i][1]].max
  else
    dp[i+1][1]=dp[i].max+1
  end
end

puts dp[N].max
0