結果

問題 No.397 NO MORE KADOMATSU
ユーザー mban259mban259
提出日時 2016-08-02 19:10:16
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 999 bytes
コンパイル時間 2,221 ms
コンパイル使用メモリ 106,016 KB
実行使用メモリ 39,856 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:24:54
合計ジャッジ時間 5,363 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
37,420 KB
testcase_01 AC 84 ms
39,536 KB
testcase_02 AC 81 ms
37,296 KB
testcase_03 AC 91 ms
39,404 KB
testcase_04 AC 85 ms
39,812 KB
testcase_05 AC 92 ms
35,404 KB
testcase_06 AC 102 ms
37,704 KB
testcase_07 AC 105 ms
37,612 KB
testcase_08 AC 90 ms
37,920 KB
testcase_09 AC 83 ms
39,788 KB
testcase_10 AC 140 ms
39,856 KB
testcase_11 AC 84 ms
37,396 KB
testcase_12 AC 109 ms
38,104 KB
testcase_13 AC 113 ms
37,468 KB
testcase_14 AC 118 ms
39,632 KB
testcase_15 AC 119 ms
39,628 KB
testcase_16 AC 83 ms
37,804 KB
testcase_17 AC 82 ms
39,368 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 Cla {
    static int N;
    static int[] A;
    static int Cnt = 0;
    static List<int[]> Change = new List<int[]>();
    static void Main() {
        N = int.Parse(Console.ReadLine());
        A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        for(int i = N - 1; i >= 1; i--) {
            for(int j = 0; j < i; j++) {
                if (A[j] > A[j + 1]) {
                    Cnt++;
                    int[] a = new int[2];
                    a[0] = j;
                    a[1] = j + 1;
                    Change.Add(a);
                    int w = A[j];
                    A[j] = A[j + 1];
                    A[j + 1] = w; 
                }
            }
        }
        Console.WriteLine(Cnt);
        for(int i = 0; i < Change.Count; i++) {
            Console.WriteLine(Change[i][0] + " " + Change[i][1]);

        }
        Console.Out.Flush();
        Console.ReadLine();
    }
}
0