結果

問題 No.482 あなたの名は
ユーザー sei0osei0o
提出日時 2017-05-12 20:37:40
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 314 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 11,356 KB
実行使用メモリ 33,652 KB
最終ジャッジ日時 2023-10-13 13:58:25
合計ジャッジ時間 6,754 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,172 KB
testcase_01 AC 87 ms
15,044 KB
testcase_02 AC 82 ms
15,056 KB
testcase_03 AC 83 ms
15,060 KB
testcase_04 AC 81 ms
15,284 KB
testcase_05 AC 83 ms
15,308 KB
testcase_06 AC 82 ms
15,192 KB
testcase_07 AC 85 ms
15,196 KB
testcase_08 AC 83 ms
15,140 KB
testcase_09 AC 83 ms
15,168 KB
testcase_10 AC 83 ms
15,148 KB
testcase_11 AC 83 ms
15,288 KB
testcase_12 AC 82 ms
15,136 KB
testcase_13 AC 82 ms
15,160 KB
testcase_14 AC 81 ms
15,152 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n, k = gets.chomp.split(" ").map(&:to_i)
d = gets.chomp.split(" ").map { |a| a.to_i - 1 }

minimum = 0
d.each_with_index do |cur_val, expected|
  next if cur_val == expected

  minimum += 1
  d[d.index(expected)] = cur_val
  d[expected] = expected
end

puts (minimum <= k && (k - minimum) % 2 == 0) ? "YES" : "NO"
0