結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,320 KB
testcase_01 AC 80 ms
15,344 KB
testcase_02 AC 79 ms
15,360 KB
testcase_03 AC 81 ms
15,532 KB
testcase_04 AC 82 ms
15,436 KB
testcase_05 AC 80 ms
15,508 KB
testcase_06 AC 80 ms
15,308 KB
testcase_07 AC 94 ms
21,888 KB
testcase_08 AC 92 ms
22,560 KB
testcase_09 AC 96 ms
23,008 KB
testcase_10 AC 136 ms
38,604 KB
testcase_11 AC 131 ms
23,236 KB
testcase_12 WA -
testcase_13 AC 111 ms
22,984 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 303 ms
34,480 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 88 ms
15,176 KB
testcase_26 WA -
testcase_27 AC 1,581 ms
70,396 KB
testcase_28 WA -
testcase_29 AC 1,391 ms
70,280 KB
testcase_30 AC 451 ms
29,108 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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|
    if a[i]-k-1 >= 0 
      dp[3][a[i]] += dp[2][a[i]-k-1]
    end
    if a[i]+k <= max_a
      dp[2][a[i]] += dp[1][a[i]+k]
    end
    if a[i]-k-10 >= 0
      dp[1][a[i]] += dp[0][a[i]-k-10]
    end
    dp[0][a[i]] += 1
  end
  ans += dp[3].sum
end
puts ans
0