結果

問題 No.482 あなたの名は
ユーザー zazaboonzazaboon
提出日時 2017-02-11 04:10:56
言語 Ruby
(3.3.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 348 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 30,892 KB
最終ジャッジ日時 2023-08-28 16:20:15
合計ジャッジ時間 5,589 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
15,256 KB
testcase_01 AC 80 ms
15,152 KB
testcase_02 AC 75 ms
15,104 KB
testcase_03 AC 74 ms
15,188 KB
testcase_04 AC 74 ms
15,348 KB
testcase_05 AC 74 ms
15,308 KB
testcase_06 AC 74 ms
15,204 KB
testcase_07 AC 76 ms
15,360 KB
testcase_08 AC 75 ms
15,176 KB
testcase_09 AC 74 ms
15,268 KB
testcase_10 AC 76 ms
15,264 KB
testcase_11 AC 75 ms
15,208 KB
testcase_12 AC 76 ms
15,276 KB
testcase_13 AC 75 ms
15,332 KB
testcase_14 AC 75 ms
15,180 KB
testcase_15 AC 185 ms
30,764 KB
testcase_16 AC 185 ms
30,444 KB
testcase_17 AC 187 ms
30,876 KB
testcase_18 AC 185 ms
30,892 KB
testcase_19 AC 185 ms
30,544 KB
testcase_20 AC 185 ms
30,704 KB
testcase_21 AC 185 ms
30,688 KB
testcase_22 AC 185 ms
30,540 KB
testcase_23 AC 186 ms
30,748 KB
testcase_24 AC 186 ms
30,684 KB
testcase_25 AC 186 ms
30,680 KB
testcase_26 AC 187 ms
30,876 KB
testcase_27 AC 186 ms
30,628 KB
testcase_28 AC 184 ms
30,572 KB
testcase_29 AC 188 ms
30,836 KB
testcase_30 AC 77 ms
15,252 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
count = 0
t = []
(0..(n-1)).each do |d|
  t[a[d]-1] = d
end
(0..(n-1)).each do |d|
  if(a[d] != (d+1))
    count += 1 
    ind = t[d]
    a[ind] = a[d]
    t[a[d]-1] = ind
  end
end
test = k - (count)
if (test < 0)
  puts "NO"
  exit
end
puts (test%2 == 0)? "YES" : "NO"
0