結果

問題 No.482 あなたの名は
ユーザー finefine
提出日時 2017-02-10 22:35:26
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 275 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 11,436 KB
実行使用メモリ 29,600 KB
最終ジャッジ日時 2023-08-27 22:29:32
合計ジャッジ時間 6,855 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,128 KB
testcase_01 AC 79 ms
15,248 KB
testcase_02 AC 77 ms
15,252 KB
testcase_03 AC 78 ms
15,080 KB
testcase_04 AC 77 ms
15,092 KB
testcase_05 WA -
testcase_06 AC 78 ms
15,160 KB
testcase_07 AC 78 ms
15,196 KB
testcase_08 AC 78 ms
15,088 KB
testcase_09 AC 77 ms
15,140 KB
testcase_10 AC 78 ms
15,068 KB
testcase_11 AC 78 ms
15,236 KB
testcase_12 WA -
testcase_13 AC 78 ms
15,216 KB
testcase_14 AC 78 ms
15,244 KB
testcase_15 AC 190 ms
29,312 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 197 ms
29,336 KB
testcase_19 AC 191 ms
29,600 KB
testcase_20 AC 189 ms
29,332 KB
testcase_21 AC 188 ms
29,388 KB
testcase_22 AC 189 ms
29,260 KB
testcase_23 AC 190 ms
29,404 KB
testcase_24 AC 190 ms
29,460 KB
testcase_25 AC 190 ms
29,272 KB
testcase_26 WA -
testcase_27 AC 192 ms
29,400 KB
testcase_28 WA -
testcase_29 AC 187 ms
29,412 KB
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k = gets.split.map(&:to_i)
a = gets.split.map{|x|x.to_i - 1}
idx = Array.new(n)
n.times do |i|
    idx[a[i]] = i
end

cnt = 0
n.times do |i|
    next if a[i] == i
    a[idx[i]] = a[i]
    cnt += 1
end

if cnt > k || (k - cnt) % 2 == 1
    puts "NO"
else
    puts "YES"
end
0