結果

問題 No.490 yukiソート
ユーザー maimai
提出日時 2017-03-11 01:21:17
言語 Ruby
(3.3.0)
結果
AC  
実行時間 958 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 11,552 KB
実行使用メモリ 15,476 KB
最終ジャッジ日時 2023-09-06 17:27:43
合計ジャッジ時間 13,373 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,040 KB
testcase_01 AC 79 ms
15,228 KB
testcase_02 AC 78 ms
15,048 KB
testcase_03 AC 79 ms
15,036 KB
testcase_04 AC 103 ms
15,236 KB
testcase_05 AC 99 ms
15,248 KB
testcase_06 AC 100 ms
15,168 KB
testcase_07 AC 100 ms
15,280 KB
testcase_08 AC 101 ms
15,328 KB
testcase_09 AC 99 ms
15,276 KB
testcase_10 AC 99 ms
15,200 KB
testcase_11 AC 100 ms
15,332 KB
testcase_12 AC 100 ms
15,208 KB
testcase_13 AC 99 ms
15,172 KB
testcase_14 AC 950 ms
15,248 KB
testcase_15 AC 954 ms
15,296 KB
testcase_16 AC 950 ms
15,296 KB
testcase_17 AC 954 ms
15,344 KB
testcase_18 AC 945 ms
15,212 KB
testcase_19 AC 956 ms
15,180 KB
testcase_20 AC 955 ms
15,212 KB
testcase_21 AC 946 ms
15,328 KB
testcase_22 AC 958 ms
15,292 KB
testcase_23 AC 943 ms
15,476 KB
testcase_24 AC 78 ms
15,304 KB
testcase_25 AC 78 ms
15,132 KB
testcase_26 AC 77 ms
15,084 KB
testcase_27 AC 78 ms
15,292 KB
testcase_28 AC 79 ms
15,248 KB
testcase_29 AC 79 ms
15,232 KB
testcase_30 AC 78 ms
15,044 KB
testcase_31 AC 79 ms
15,044 KB
testcase_32 AC 78 ms
15,040 KB
testcase_33 AC 79 ms
15,048 KB
testcase_34 AC 79 ms
15,120 KB
testcase_35 AC 80 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def scan; gets.split.map(&:to_i);end

# 各 i (0<i<2n−3) に対して、2. を行う
# p+q=i (0≤p<q≤n−1) を満たす整数の組 (p,q)(p,q) 全てに対して、ap>aq ならば apap と aqaq を交換する

n=scan[0]
a=scan

1.upto(2*n-4){|i|
    0.upto(i){|_p|
        q=i-_p
        next if q>=n||_p>=n
        next if _p>q
        abort unless _p+q==i
        a[_p],a[q]=a[q],a[_p] if a[_p] > a[q]
    }
}

puts a*" "
0