結果

問題 No.482 あなたの名は
ユーザー ryoo14ryoo14
提出日時 2017-02-11 10:23:46
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 288 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 33,932 KB
最終ジャッジ日時 2023-08-28 12:46:46
合計ジャッジ時間 5,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
22,212 KB
testcase_01 AC 85 ms
15,084 KB
testcase_02 AC 83 ms
15,296 KB
testcase_03 AC 79 ms
15,284 KB
testcase_04 AC 79 ms
15,048 KB
testcase_05 AC 79 ms
15,148 KB
testcase_06 AC 79 ms
15,188 KB
testcase_07 AC 82 ms
15,356 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 80 ms
15,156 KB
testcase_11 AC 81 ms
15,048 KB
testcase_12 AC 80 ms
15,084 KB
testcase_13 AC 80 ms
15,260 KB
testcase_14 AC 78 ms
15,144 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k = gets.split.map(&:to_i)
d = gets.split.map(&:to_i)
d = d.map { |v| v-1 }
cnt = 0

n.times do |i|
  if d[i] == i
    next
  else
    t = d.index(i)
    tm = d[t]
    d[t] = d[i]
    d[i] = tm
    cnt += 1
  end
end

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