結果
問題 | No.1374 Absolute Game |
ユーザー | magurofly |
提出日時 | 2021-02-05 22:21:05 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 387 bytes |
コンパイル時間 | 761 ms |
コンパイル使用メモリ | 11,312 KB |
実行使用メモリ | 20,276 KB |
最終ジャッジ日時 | 2023-09-15 08:39:08 |
合計ジャッジ時間 | 5,779 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 79 ms
20,276 KB |
testcase_01 | AC | 79 ms
15,116 KB |
testcase_02 | AC | 80 ms
15,092 KB |
testcase_03 | AC | 79 ms
15,156 KB |
testcase_04 | AC | 78 ms
15,252 KB |
testcase_05 | AC | 78 ms
15,024 KB |
testcase_06 | AC | 79 ms
15,292 KB |
testcase_07 | WA | - |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i c = gets.split.map(&:to_i).sort dp = [[0, 0]] * (N+1) (1 .. N).each do |s| dp1 = [] (0 .. N-s).each do |l| b1, a1 = dp[l] b2, a2 = dp[l+1] a1 += c[l+s-1] a2 += c[l] dp1[l] = [ [a1, b1], [a2, b2], ].max_by { |(a, b)| a.abs - b.abs } end dp = dp1 end a, b = dp[0] puts a.abs - b.abs