結果

問題 No.2374 ASKT Subsequences
ユーザー KowerKoint2010KowerKoint2010
提出日時 2023-06-28 17:57:02
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 11,220 KB
実行使用メモリ 70,556 KB
最終ジャッジ日時 2023-09-18 22:00:42
合計ジャッジ時間 13,023 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,168 KB
testcase_01 WA -
testcase_02 AC 81 ms
15,240 KB
testcase_03 WA -
testcase_04 AC 80 ms
15,588 KB
testcase_05 AC 80 ms
15,312 KB
testcase_06 WA -
testcase_07 AC 95 ms
21,752 KB
testcase_08 AC 93 ms
22,480 KB
testcase_09 AC 96 ms
22,800 KB
testcase_10 AC 137 ms
38,516 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 84 ms
15,008 KB
testcase_26 WA -
testcase_27 AC 1,573 ms
70,216 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0
max_a = a.max
0.upto(max_a) do |k|
  dp = Array.new(4) { Array.new(max_a+1, 0) }
  n.times do |i|
    dp[0][a[i]] += 1
    if a[i]-k-10 >= 0
      dp[1][a[i]] += dp[0][a[i]-k-10]
    end
    if a[i]+k <= max_a
      dp[2][a[i]] += dp[1][a[i]+k]
    end
    if a[i]-k-1 >= 0 
      dp[3][a[i]] += dp[2][a[i]-k-1]
    end
  end
  ans += dp[3].sum
end
puts ans
0