結果

問題 No.397 NO MORE KADOMATSU
ユーザー 14番14番
提出日時 2016-07-16 00:19:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 2,057 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 106,552 KB
実行使用メモリ 39,952 KB
平均クエリ数 36.83
最終ジャッジ日時 2023-09-24 00:19:09
合計ジャッジ時間 4,872 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
39,756 KB
testcase_01 AC 84 ms
37,792 KB
testcase_02 AC 83 ms
35,796 KB
testcase_03 AC 86 ms
39,952 KB
testcase_04 AC 86 ms
37,480 KB
testcase_05 AC 86 ms
37,608 KB
testcase_06 AC 86 ms
38,080 KB
testcase_07 AC 89 ms
37,848 KB
testcase_08 AC 87 ms
38,240 KB
testcase_09 AC 83 ms
38,172 KB
testcase_10 AC 85 ms
37,564 KB
testcase_11 AC 87 ms
39,308 KB
testcase_12 AC 87 ms
39,544 KB
testcase_13 AC 84 ms
37,656 KB
testcase_14 AC 86 ms
37,928 KB
testcase_15 AC 89 ms
38,064 KB
testcase_16 AC 87 ms
37,984 KB
testcase_17 AC 86 ms
37,412 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.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int matsuCount = int.Parse(Reader.ReadLine());
        int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();
        matsuCount = inpt.Length;

        inpt.ToList().ForEach(a=>this.Matsu.Add(this.Matsu.Count, a));

        StringBuilder ans = new StringBuilder();
        int conv = 0;
        for(int i=0; i<matsuCount; i++) {
            int min = this.Matsu.Where(a=>a.Key >= i).OrderBy(a=>a.Value).First().Key;
            if(i != min) {
                conv++;
                ans.AppendLine(i + " " + min);
                int tmp = this.Matsu[i];
                this.Matsu[i] = this.Matsu[min];
                this.Matsu[min] = tmp;
            }
        }
        Console.WriteLine(conv);
        Console.Write(ans.ToString());
        string dummy = Reader.ReadLine();
    }

    private Dictionary<int, int> Matsu = new Dictionary<int,int>();
    private Dictionary<int, int> Goal = new Dictionary<int, int>();

    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"



6
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 11 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
-1

 
";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }

    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0