結果

問題 No.482 あなたの名は
ユーザー zazaboonzazaboon
提出日時 2017-02-10 22:56:42
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 328 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 30,848 KB
最終ジャッジ日時 2023-08-27 23:15:35
合計ジャッジ時間 6,373 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,244 KB
testcase_01 AC 81 ms
15,236 KB
testcase_02 AC 81 ms
15,296 KB
testcase_03 AC 81 ms
15,040 KB
testcase_04 AC 80 ms
15,352 KB
testcase_05 WA -
testcase_06 AC 80 ms
15,136 KB
testcase_07 AC 81 ms
15,140 KB
testcase_08 AC 81 ms
15,176 KB
testcase_09 AC 81 ms
15,140 KB
testcase_10 AC 82 ms
15,260 KB
testcase_11 AC 80 ms
15,260 KB
testcase_12 WA -
testcase_13 AC 81 ms
15,196 KB
testcase_14 AC 82 ms
15,148 KB
testcase_15 AC 197 ms
30,848 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 199 ms
30,700 KB
testcase_19 AC 198 ms
30,628 KB
testcase_20 AC 196 ms
30,816 KB
testcase_21 AC 196 ms
30,676 KB
testcase_22 AC 197 ms
30,688 KB
testcase_23 AC 198 ms
30,792 KB
testcase_24 AC 200 ms
30,724 KB
testcase_25 AC 199 ms
30,524 KB
testcase_26 WA -
testcase_27 AC 194 ms
30,376 KB
testcase_28 WA -
testcase_29 AC 192 ms
30,664 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]
  end
end
test = k - (count)
if (test < 0)
  puts "NO"
  exit
end
puts (test%2 == 0)? "YES" : "NO"
0