結果

問題 No.397 NO MORE KADOMATSU
ユーザー mbanmban
提出日時 2016-11-10 15:57:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 106,224 KB
実行使用メモリ 39,632 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:41:51
合計ジャッジ時間 5,336 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
35,772 KB
testcase_01 AC 91 ms
39,592 KB
testcase_02 AC 85 ms
39,632 KB
testcase_03 AC 98 ms
37,544 KB
testcase_04 AC 92 ms
37,740 KB
testcase_05 AC 98 ms
37,504 KB
testcase_06 AC 108 ms
35,492 KB
testcase_07 AC 109 ms
35,972 KB
testcase_08 AC 94 ms
39,456 KB
testcase_09 AC 86 ms
38,024 KB
testcase_10 AC 143 ms
37,504 KB
testcase_11 AC 85 ms
35,840 KB
testcase_12 AC 113 ms
38,180 KB
testcase_13 AC 118 ms
37,548 KB
testcase_14 AC 124 ms
37,876 KB
testcase_15 AC 119 ms
38,080 KB
testcase_16 AC 85 ms
37,512 KB
testcase_17 AC 85 ms
37,312 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;

class Magatro
{
   
    static void Main()
    {
        List<string> L = new List<string>();
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        for(int i = N; i >=1; i--)
        {
            for(int j = 0; j < i-1; j++)
            {
                if (a[j] > a[j + 1])
                {
                    int q = a[j];
                    a[j] = a[j+1] ;
                    a[j + 1] = q;
                    L.Add(string.Format("{0} {1}", j, j + 1));
                }
            }
        }
        Console.WriteLine(L.Count);
        for(int i = 0; i < L.Count; i++)
        {
            Console.WriteLine(L[i]);
        }
        Console.WriteLine();
    }
   
   
}
0