結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
15,160 KB
testcase_01 AC 83 ms
15,264 KB
testcase_02 AC 83 ms
15,088 KB
testcase_03 AC 87 ms
15,188 KB
testcase_04 AC 83 ms
15,128 KB
testcase_05 AC 84 ms
15,220 KB
testcase_06 AC 83 ms
15,108 KB
testcase_07 AC 84 ms
15,192 KB
testcase_08 AC 83 ms
15,244 KB
testcase_09 AC 83 ms
15,048 KB
testcase_10 AC 83 ms
15,240 KB
testcase_11 AC 83 ms
15,040 KB
testcase_12 AC 83 ms
15,076 KB
testcase_13 AC 83 ms
15,164 KB
testcase_14 AC 82 ms
15,116 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

a = k - cnt
if a < 0 
  puts "NO"
elsif cnt == k || a % 2 == 0
  puts "YES"
else
  puts "NO"
end
0