結果

問題 No.490 yukiソート
ユーザー mbanmban
提出日時 2017-03-11 19:24:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 2,815 bytes
コンパイル時間 3,006 ms
コンパイル使用メモリ 105,836 KB
実行使用メモリ 24,100 KB
最終ジャッジ日時 2023-09-06 18:12:03
合計ジャッジ時間 6,803 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
19,640 KB
testcase_01 AC 64 ms
23,780 KB
testcase_02 AC 63 ms
21,616 KB
testcase_03 AC 65 ms
21,756 KB
testcase_04 AC 71 ms
21,808 KB
testcase_05 AC 72 ms
21,736 KB
testcase_06 AC 71 ms
21,892 KB
testcase_07 AC 72 ms
23,848 KB
testcase_08 AC 71 ms
23,880 KB
testcase_09 AC 71 ms
21,808 KB
testcase_10 AC 72 ms
19,796 KB
testcase_11 AC 71 ms
21,792 KB
testcase_12 AC 71 ms
21,792 KB
testcase_13 AC 72 ms
23,832 KB
testcase_14 AC 99 ms
24,088 KB
testcase_15 AC 98 ms
24,000 KB
testcase_16 AC 99 ms
19,916 KB
testcase_17 AC 98 ms
23,960 KB
testcase_18 AC 99 ms
24,028 KB
testcase_19 AC 98 ms
22,004 KB
testcase_20 AC 99 ms
24,100 KB
testcase_21 AC 98 ms
21,960 KB
testcase_22 AC 97 ms
21,968 KB
testcase_23 AC 98 ms
22,064 KB
testcase_24 AC 65 ms
23,744 KB
testcase_25 AC 64 ms
21,640 KB
testcase_26 AC 64 ms
21,756 KB
testcase_27 AC 64 ms
21,804 KB
testcase_28 AC 64 ms
21,700 KB
testcase_29 AC 63 ms
21,712 KB
testcase_30 AC 64 ms
23,676 KB
testcase_31 AC 65 ms
21,624 KB
testcase_32 AC 64 ms
21,704 KB
testcase_33 AC 64 ms
21,624 KB
testcase_34 AC 65 ms
23,660 KB
testcase_35 AC 64 ms
21,632 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.ComponentModel;

class Program
{
    static void Main(string[] args)
    {
        var alice = new Magatro();
        alice.Scan();
        alice.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;
    private const char Separator = ' ';

    public Scanner() : this(Console.OpenStandardInput())
    {
        Index = 0;
        S = new string[0];
    }
    public Scanner(Stream source)
    {
        Sr = new StreamReader(source);
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public T Next<T>()
    {
        var converter = TypeDescriptor.GetConverter(typeof(T));
        return (T)converter.ConvertFromString(Next());

    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public decimal NextDecimal()
    {
        return decimal.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private int N;
    private int[] A;
    public void Scan()
    {
        Scanner cin = new Scanner();
        N = cin.NextInt();
        A = cin.IntArray();
    }

    public void Solve()
    {
        for (int i = 1; i < 2 * N - 3; i++)
        {
            for (int p = 0; p <= N - 1; p++)
            {
                int q = i - p;
                if (0 <= q && q <= N - 1)
                {
                    if (p < q)
                    {
                        if (A[p] > A[q])
                        {
                            Swap(ref A[p], ref A[q]);
                        }
                    }
                }
            }
        }
        Console.WriteLine(string.Join(" ", A));
    }

    private void Swap(ref int a, ref int b)
    {
        var temp = a;
        a = b;
        b = temp;
    }
}

0