結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
もいちゃん
|
| 提出日時 | 2017-03-09 15:56:51 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 408 bytes |
| コンパイル時間 | 66 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 25,600 KB |
| 最終ジャッジ日時 | 2024-06-24 00:06:55 |
| 合計ジャッジ時間 | 6,617 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 8 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
n, k = gets.split().map(&:to_i)
nums = gets.split().map(&:to_i)
a,b,score = 0,0,0
nums.each_with_index do |c,i|
if i+1 == c
next
elsif i+1 == nums[c-1]
a += 1
elsif i+1 != nums[c-1]
b += 1
end
end
score += a / 2 if a > 1
score += b - 1 if b > 2
if score % 2 == 0 && k % 2 == 0 && score <= k
puts "YES"
elsif score % 2 != 0 && k % 2 != 0 && score <= k
puts "YES"
else
puts "NO"
end
もいちゃん