結果

問題 No.482 あなたの名は
ユーザー zazaboonzazaboon
提出日時 2017-02-11 04:07:41
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 351 bytes
コンパイル時間 38 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 31,080 KB
最終ジャッジ日時 2023-08-28 12:45:49
合計ジャッジ時間 5,740 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,104 KB
testcase_01 AC 82 ms
15,252 KB
testcase_02 AC 82 ms
15,280 KB
testcase_03 AC 81 ms
15,148 KB
testcase_04 AC 86 ms
15,044 KB
testcase_05 WA -
testcase_06 AC 79 ms
15,148 KB
testcase_07 AC 79 ms
15,036 KB
testcase_08 AC 79 ms
15,040 KB
testcase_09 AC 78 ms
15,160 KB
testcase_10 AC 79 ms
15,276 KB
testcase_11 AC 81 ms
15,036 KB
testcase_12 AC 80 ms
15,352 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 199 ms
30,388 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 198 ms
30,776 KB
testcase_22 AC 201 ms
30,652 KB
testcase_23 AC 197 ms
30,712 KB
testcase_24 WA -
testcase_25 AC 202 ms
30,536 KB
testcase_26 AC 199 ms
30,816 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 199 ms
30,804 KB
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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] = t[ind]
  end
end
test = k - (count)
if (test < 0)
  puts "NO"
  exit
end
puts (test%2 == 0)? "YES" : "NO"
0