結果

問題 No.482 あなたの名は
ユーザー zazaboonzazaboon
提出日時 2017-02-10 23:01:12
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 346 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 30,884 KB
最終ジャッジ日時 2023-08-27 23:19:26
合計ジャッジ時間 6,123 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,168 KB
testcase_01 AC 80 ms
15,052 KB
testcase_02 AC 79 ms
15,060 KB
testcase_03 AC 80 ms
15,120 KB
testcase_04 AC 78 ms
15,268 KB
testcase_05 WA -
testcase_06 AC 79 ms
15,060 KB
testcase_07 AC 80 ms
15,008 KB
testcase_08 AC 81 ms
15,160 KB
testcase_09 AC 80 ms
15,048 KB
testcase_10 AC 80 ms
15,116 KB
testcase_11 AC 80 ms
15,324 KB
testcase_12 WA -
testcase_13 AC 80 ms
15,132 KB
testcase_14 AC 80 ms
15,148 KB
testcase_15 AC 196 ms
30,632 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 198 ms
30,732 KB
testcase_19 AC 200 ms
30,764 KB
testcase_20 AC 197 ms
30,536 KB
testcase_21 AC 195 ms
30,864 KB
testcase_22 AC 195 ms
30,372 KB
testcase_23 AC 200 ms
30,884 KB
testcase_24 AC 197 ms
30,752 KB
testcase_25 AC 196 ms
30,472 KB
testcase_26 WA -
testcase_27 AC 197 ms
30,488 KB
testcase_28 WA -
testcase_29 AC 193 ms
30,696 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] = d
  end
end
test = k - (count)
if (test < 0)
  puts "NO"
  exit
end
puts (test%2 == 0)? "YES" : "NO"
0