結果

問題 No.397 NO MORE KADOMATSU
ユーザー claw88claw88
提出日時 2016-07-16 00:11:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,310 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 103,308 KB
実行使用メモリ 38,992 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:19:03
合計ジャッジ時間 4,568 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
36,372 KB
testcase_01 AC 74 ms
36,300 KB
testcase_02 AC 75 ms
34,992 KB
testcase_03 AC 75 ms
36,308 KB
testcase_04 AC 76 ms
38,884 KB
testcase_05 AC 79 ms
38,992 KB
testcase_06 AC 79 ms
36,452 KB
testcase_07 AC 77 ms
36,772 KB
testcase_08 AC 77 ms
36,684 KB
testcase_09 AC 76 ms
38,752 KB
testcase_10 AC 96 ms
38,784 KB
testcase_11 AC 76 ms
36,712 KB
testcase_12 AC 82 ms
34,944 KB
testcase_13 AC 87 ms
38,696 KB
testcase_14 AC 85 ms
38,956 KB
testcase_15 AC 85 ms
37,060 KB
testcase_16 AC 75 ms
37,168 KB
testcase_17 AC 73 ms
36,300 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.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yuki0715_D
{
    class Program
    {
        
     
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            int n = getint();
            var x = getsplit();
            var a = Array.ConvertAll(x, int.Parse);
            bool s = true;
            int count = 0;
            while (s)
            {
                s = false;
                for (int j = n - 1; j > 0; j--)
                {
                    if (a[j] < a[j - 1])
                    {
                        int k = a[j - 1];
                        a[j - 1] = a[j];
                        a[j] = k;
                        sb.AppendLine(j-1 + " "+j);
                        count++;
                        s = true;
                    }
                }
            }
            Console.WriteLine(count);
            Console.Write(sb);
            n = getint();
        }
       
        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}
0