結果

問題 No.482 あなたの名は
ユーザー ryoo14ryoo14
提出日時 2017-02-11 10:38:06
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 289 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 29,648 KB
最終ジャッジ日時 2023-08-28 12:48:08
合計ジャッジ時間 5,921 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,304 KB
testcase_01 AC 79 ms
15,120 KB
testcase_02 AC 80 ms
15,036 KB
testcase_03 AC 81 ms
15,116 KB
testcase_04 AC 81 ms
15,164 KB
testcase_05 AC 80 ms
15,076 KB
testcase_06 AC 82 ms
15,096 KB
testcase_07 AC 82 ms
15,296 KB
testcase_08 WA -
testcase_09 AC 82 ms
15,244 KB
testcase_10 AC 82 ms
15,076 KB
testcase_11 AC 84 ms
15,028 KB
testcase_12 WA -
testcase_13 AC 82 ms
15,240 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 193 ms
29,328 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 190 ms
29,324 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 191 ms
29,276 KB
testcase_24 AC 190 ms
29,272 KB
testcase_25 AC 192 ms
29,324 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 186 ms
29,412 KB
testcase_29 AC 189 ms
29,500 KB
testcase_30 AC 78 ms
15,244 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n,k = gets.split.map(&:to_i)
d = gets.split.map(&:to_i)
d = d.map { |v| v-1 }
cnt = 0

d.each_with_index do |v,i|
  if v == i
    next
  else
    d[v] = v
    d[i] = i
    cnt += 1
  end
end

a = k - cnt
if a < 0 
  puts "NO"
elsif cnt == k || a % 2 == 0
  puts "YES"
else
  puts "NO"
end
0