結果
問題 | No.326 あみだますたー |
ユーザー |
|
提出日時 | 2016-06-05 01:29:28 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 464 bytes |
コンパイル時間 | 260 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-12-26 16:54:32 |
合計ジャッジ時間 | 4,780 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.to_ik = gets.to_ia = [*0...n]k.times{x, y = gets.split.map(&:to_i)x -= 1y -= 1tmp = a[x]a[x] = a[y]a[y] = tmp}b = gets.split.map(&:to_i)ans = []n.times{|i|1.upto(n - i - 1){|j|if b[a[j]] < b[a[j - 1]]tmp = a[j]a[j] = a[j - 1]a[j - 1] = tmpans.push(j)end}}s = ans.sizep ss.times{|i|puts "#{ans[i]} #{ans[i] + 1}"}