結果

問題 No.1373 Directed Operations
ユーザー maguroflymagurofly
提出日時 2021-02-05 21:42:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 702 ms / 2,000 ms
コード長 279 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 32,136 KB
最終ジャッジ日時 2023-09-15 07:32:26
合計ジャッジ時間 11,143 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,036 KB
testcase_01 AC 79 ms
15,084 KB
testcase_02 AC 486 ms
31,132 KB
testcase_03 AC 406 ms
28,264 KB
testcase_04 AC 408 ms
28,672 KB
testcase_05 AC 82 ms
15,168 KB
testcase_06 AC 683 ms
32,040 KB
testcase_07 AC 93 ms
15,272 KB
testcase_08 AC 135 ms
16,276 KB
testcase_09 AC 590 ms
28,592 KB
testcase_10 AC 503 ms
22,824 KB
testcase_11 AC 176 ms
16,936 KB
testcase_12 AC 501 ms
22,676 KB
testcase_13 AC 125 ms
15,692 KB
testcase_14 AC 700 ms
31,732 KB
testcase_15 AC 632 ms
23,852 KB
testcase_16 AC 702 ms
32,136 KB
testcase_17 AC 510 ms
23,364 KB
testcase_18 AC 257 ms
23,624 KB
testcase_19 AC 303 ms
22,756 KB
testcase_20 AC 400 ms
24,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
a = gets.split.map(&:to_i)

b = a.each_with_index.to_a.sort
c = []
dp = [false] * N
dp[0] = true
b.each_with_index do |(l, j), i|
    x = i + 1 - l
    c[j] = x + 1
    dp[i+1] = dp[x] if x >= 0
end

if dp.all?(true)
    puts "YES"
    puts c
else
    puts "NO"
end
0