結果

問題 No.482 あなたの名は
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-27 20:04:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 205 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,492 KB
実行使用メモリ 27,996 KB
最終ジャッジ日時 2023-09-07 19:05:10
合計ジャッジ時間 5,305 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,004 KB
testcase_01 AC 85 ms
15,316 KB
testcase_02 AC 76 ms
15,324 KB
testcase_03 AC 77 ms
15,260 KB
testcase_04 AC 76 ms
15,108 KB
testcase_05 AC 76 ms
15,224 KB
testcase_06 AC 77 ms
15,180 KB
testcase_07 AC 76 ms
15,100 KB
testcase_08 AC 76 ms
15,128 KB
testcase_09 AC 77 ms
15,128 KB
testcase_10 AC 77 ms
15,340 KB
testcase_11 AC 76 ms
15,100 KB
testcase_12 AC 77 ms
15,264 KB
testcase_13 AC 76 ms
15,000 KB
testcase_14 AC 79 ms
15,264 KB
testcase_15 AC 173 ms
27,768 KB
testcase_16 AC 173 ms
27,768 KB
testcase_17 AC 173 ms
27,992 KB
testcase_18 AC 175 ms
27,660 KB
testcase_19 AC 171 ms
27,812 KB
testcase_20 AC 170 ms
27,760 KB
testcase_21 AC 172 ms
27,960 KB
testcase_22 AC 171 ms
27,980 KB
testcase_23 AC 179 ms
27,764 KB
testcase_24 AC 172 ms
27,996 KB
testcase_25 AC 172 ms
27,932 KB
testcase_26 AC 171 ms
27,712 KB
testcase_27 AC 174 ms
27,768 KB
testcase_28 AC 173 ms
27,820 KB
testcase_29 AC 176 ms
27,924 KB
testcase_30 AC 78 ms
15,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - hs
Main.rb:4: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

n,k=gets.split.map{|e| e.to_i}
x=gets.split.map{|e| e.to_i-1}
hs={}
i=0
n.times{|i|
	while x[i]!=i
		t=x[i]
		x[i]=x[t]
		x[t]=t
		k-=1
	end
}
if k<0
	puts "NO"
elsif k%2==0
	puts "YES"
else
	puts "NO"
end
0