結果

問題 No.365 ジェンガソート
ユーザー mori_chibi
提出日時 2017-08-21 14:26:31
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,010 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 107,136 KB
実行使用メモリ 29,696 KB
最終ジャッジ日時 2024-10-15 00:49:35
合計ジャッジ時間 5,150 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 TLE * 1 -- * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;

namespace GengaSort
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<int> An = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray());
            if (N > An.Count) N = An.Count;
            int ix = 0, count = 0, max,item;
            while(ix > -1)
            {
                ix = -1;
                max = 0;
                for (int i = 0; i < An.Count - 1; i++)
                {
                    if (An[i] > max) max = An[i];
                    if (max > An[i + 1] && (ix == -1 || An[ix] < An[i + 1])) ix = i + 1;
                }
                if (ix > -1)
                {
                    count++;
                    item = An[ix];
                    An.Remove(item);
                    An.Insert(0, item);
                }
            }
            Console.WriteLine(count);
        }
    }
}
0