結果

問題 No.490 yukiソート
ユーザー nanaenanae
提出日時 2017-03-10 22:37:13
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 164,096 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 07:18:03
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    auto n = readln.chomp.to!int;
    auto a = readln.split.to!(int[]);


    foreach(i ; 1 .. 2*n - 3){
        foreach(p ; 0 .. (i+1)/2){
            int q = i - p;
            if(p != q && 0 <= q && q < n){
                if(a[p] > a[q]){
                    swap(a[p], a[q]);
                }
            }
        }
    }

    writefln("%(%s %)", a);
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}
0