結果

問題 No.490 yukiソート
ユーザー No
提出日時 2017-05-28 01:59:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 115,060 KB
実行使用メモリ 20,096 KB
最終ジャッジ日時 2024-09-21 14:36:30
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Text;
namespace Yuki
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();

            for (int i = 1; i < 2 * n - 3; i++)
            {
                for (int p = 0; p <= n - 1; p++)
                {
                    int q = i - p;
                    if (p >= q) break;
                    if (p > a.Length - 1) break;
                    if (q > a.Length - 1) continue;
                    if (a[p] > a[q])
                    {
                        int w = a[p];
                        a[p] = a[q];
                        a[q] = w;
                    }
                }
            }

            var sb = new StringBuilder();
            foreach (var item in a)
            {
                sb.Append(item.ToString() + " ");
            }

            Console.WriteLine(sb.ToString().Trim());
        }
    }
}
0