結果

問題 No.482 あなたの名は
ユーザー suppy193suppy193
提出日時 2017-02-13 09:53:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 418 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 29,264 KB
最終ジャッジ日時 2023-08-28 15:08:22
合計ジャッジ時間 5,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,300 KB
testcase_01 AC 79 ms
15,288 KB
testcase_02 WA -
testcase_03 AC 79 ms
15,044 KB
testcase_04 AC 78 ms
15,344 KB
testcase_05 WA -
testcase_06 AC 79 ms
15,312 KB
testcase_07 WA -
testcase_08 AC 80 ms
15,116 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 78 ms
15,176 KB
testcase_15 AC 168 ms
29,012 KB
testcase_16 AC 168 ms
29,104 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 168 ms
29,108 KB
testcase_20 WA -
testcase_21 AC 167 ms
29,008 KB
testcase_22 AC 167 ms
29,220 KB
testcase_23 AC 168 ms
29,168 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 168 ms
29,080 KB
testcase_28 AC 167 ms
29,108 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k = gets.strip.split(' ').map(&:to_i)
d = gets.strip.split(' ').map(&:to_i)
count = 0
(1..n).each do |i|
	count += 1 if d[i - 1] != i
end
# p count
if count / 2 < k
 	puts "NO"
elsif count == 0 && k % 2 == 0
	puts "YES"
elsif count == 0 && k % 2 == 1
	puts "NO"
elsif count % 2 == 1 && k % 2 == 0
	puts "YES"
elsif count % 2 == 0 && k % 2 == 1
	puts "YES"
elsif count >= 4 && k >= 3
	puts "YES"
else 
	puts "NO"
end
0