結果

問題 No.1512 作文
ユーザー simansiman
提出日時 2021-05-23 18:28:16
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,333 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 40,960 KB
最終ジャッジ日時 2024-04-20 03:43:17
合計ジャッジ時間 10,548 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
12,416 KB
testcase_01 AC 78 ms
12,416 KB
testcase_02 AC 75 ms
12,160 KB
testcase_03 AC 77 ms
12,160 KB
testcase_04 AC 645 ms
30,720 KB
testcase_05 AC 649 ms
30,720 KB
testcase_06 AC 655 ms
30,848 KB
testcase_07 AC 653 ms
30,720 KB
testcase_08 AC 643 ms
30,336 KB
testcase_09 AC 94 ms
12,928 KB
testcase_10 AC 100 ms
15,104 KB
testcase_11 AC 95 ms
13,440 KB
testcase_12 AC 96 ms
14,848 KB
testcase_13 AC 100 ms
15,104 KB
testcase_14 AC 146 ms
14,080 KB
testcase_15 AC 145 ms
14,080 KB
testcase_16 AC 144 ms
14,080 KB
testcase_17 AC 146 ms
13,952 KB
testcase_18 AC 144 ms
13,952 KB
testcase_19 AC 146 ms
14,080 KB
testcase_20 AC 146 ms
13,952 KB
testcase_21 AC 82 ms
12,800 KB
testcase_22 AC 77 ms
12,544 KB
testcase_23 AC 77 ms
12,800 KB
testcase_24 AC 78 ms
12,800 KB
testcase_25 AC 82 ms
12,672 KB
testcase_26 AC 73 ms
12,288 KB
testcase_27 AC 70 ms
12,288 KB
testcase_28 AC 70 ms
12,160 KB
testcase_29 AC 73 ms
12,288 KB
testcase_30 AC 72 ms
12,416 KB
testcase_31 AC 75 ms
12,416 KB
testcase_32 AC 80 ms
12,288 KB
testcase_33 AC 75 ms
12,288 KB
testcase_34 AC 81 ms
12,800 KB
testcase_35 AC 172 ms
27,008 KB
testcase_36 AC 175 ms
27,008 KB
testcase_37 AC 139 ms
20,864 KB
testcase_38 AC 162 ms
12,672 KB
testcase_39 AC 157 ms
13,184 KB
testcase_40 AC 1,035 ms
40,960 KB
testcase_41 AC 1,333 ms
40,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = N.times.map { gets.chomp }
T = S.select { |s| s.chars.each_cons(2).all? { |a, b| a <= b } }.sort
dp = Array.new(26, 0)
D = 'a'.ord

T.each do |t|
  i = t[0].ord - D
  j = t[-1].ord - D
  v = t.size

  (0..i).to_a.reverse_each do |c|
    len = dp[c] + v

    if dp[j] < len
      dp[j] = len
    end
  end
end

puts dp.max
0