結果

問題 No.482 あなたの名は
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-01-22 19:09:39
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 243 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 11,476 KB
実行使用メモリ 29,620 KB
最終ジャッジ日時 2023-09-22 21:20:15
合計ジャッジ時間 7,748 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,320 KB
testcase_01 AC 79 ms
15,172 KB
testcase_02 AC 79 ms
15,116 KB
testcase_03 AC 79 ms
15,072 KB
testcase_04 AC 79 ms
15,176 KB
testcase_05 AC 79 ms
15,164 KB
testcase_06 AC 78 ms
15,304 KB
testcase_07 AC 79 ms
15,260 KB
testcase_08 WA -
testcase_09 AC 78 ms
15,016 KB
testcase_10 AC 78 ms
15,160 KB
testcase_11 AC 79 ms
15,276 KB
testcase_12 WA -
testcase_13 AC 78 ms
15,128 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 189 ms
29,564 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 193 ms
29,468 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 192 ms
29,480 KB
testcase_24 AC 191 ms
29,460 KB
testcase_25 AC 190 ms
29,460 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 197 ms
29,264 KB
testcase_29 AC 189 ms
29,368 KB
testcase_30 AC 78 ms
15,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
D = gets.split.map(&:to_i).map{|d| d - 1 }
min = D.each_index.inject(0) do |s, i|
  d = D[i]
  if i == d
    s
  else
    D[i] = D[d]
    D[d] = d
    s + 1
  end
end
puts min <= K && (K - min).even? ? :YES : :NO
0