結果

問題 No.921 ずんだアロー
ユーザー __salty_life__salty_life
提出日時 2019-11-09 00:20:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 26,456 KB
最終ジャッジ日時 2023-10-13 05:54:14
合計ジャッジ時間 5,369 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,144 KB
testcase_01 AC 80 ms
15,284 KB
testcase_02 AC 80 ms
15,208 KB
testcase_03 AC 81 ms
15,040 KB
testcase_04 AC 83 ms
15,268 KB
testcase_05 AC 82 ms
15,148 KB
testcase_06 AC 80 ms
15,088 KB
testcase_07 AC 83 ms
15,064 KB
testcase_08 AC 81 ms
15,048 KB
testcase_09 AC 81 ms
15,364 KB
testcase_10 AC 160 ms
20,988 KB
testcase_11 AC 172 ms
26,132 KB
testcase_12 AC 99 ms
16,344 KB
testcase_13 AC 146 ms
20,452 KB
testcase_14 AC 151 ms
20,664 KB
testcase_15 AC 125 ms
20,332 KB
testcase_16 AC 88 ms
15,492 KB
testcase_17 AC 156 ms
20,876 KB
testcase_18 AC 179 ms
26,336 KB
testcase_19 AC 178 ms
26,336 KB
testcase_20 AC 182 ms
26,456 KB
testcase_21 AC 182 ms
26,320 KB
testcase_22 AC 179 ms
26,168 KB
testcase_23 AC 177 ms
26,320 KB
testcase_24 AC 179 ms
26,320 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
  else
    dp[i+1][1]=dp[i].max+1
  end
end

puts dp[N].max
0