結果

問題 No.326 あみだますたー
ユーザー AreTrashAreTrash
提出日時 2016-05-02 13:49:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,195 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 106,496 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-25 12:45:44
合計ジャッジ時間 2,459 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
17,792 KB
testcase_01 AC 22 ms
18,048 KB
testcase_02 AC 22 ms
18,048 KB
testcase_03 AC 30 ms
18,944 KB
testcase_04 AC 27 ms
17,920 KB
testcase_05 AC 21 ms
18,048 KB
testcase_06 AC 24 ms
18,560 KB
testcase_07 AC 21 ms
17,920 KB
testcase_08 AC 32 ms
18,048 KB
testcase_09 AC 35 ms
18,816 KB
testcase_10 AC 35 ms
18,940 KB
testcase_11 AC 21 ms
17,920 KB
testcase_12 AC 29 ms
18,432 KB
testcase_13 AC 26 ms
18,688 KB
testcase_14 AC 22 ms
18,048 KB
testcase_15 AC 24 ms
18,304 KB
testcase_16 AC 24 ms
18,560 KB
testcase_17 AC 26 ms
18,304 KB
testcase_18 AC 24 ms
18,304 KB
testcase_19 AC 25 ms
18,304 KB
testcase_20 AC 21 ms
17,920 KB
testcase_21 AC 21 ms
17,920 KB
testcase_22 AC 29 ms
18,432 KB
testcase_23 AC 33 ms
18,432 KB
testcase_24 AC 30 ms
18,688 KB
testcase_25 AC 31 ms
18,560 KB
testcase_26 AC 24 ms
17,920 KB
testcase_27 AC 30 ms
18,432 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;

namespace No326_1{
    public class Program{//(T T)
        public static void Main(string[] args){
            var n = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());

            var xn = new int[k];
            for(var i = 0; i < k; i++) xn[i] = int.Parse(Console.ReadLine().Split(' ')[0]);

            var seq = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            foreach(var x in xn){
                var tmp = seq[x];
                seq[x] = seq[x - 1];
                seq[x - 1] = tmp;
            }

            var resultList = new List<int>();
            for(var i = 1; i < n; i++){
                for(var j = 1; j < n - i + 1; j++){
                    if(seq[j] < seq[j - 1]){
                        var tmp = seq[j];
                        seq[j] = seq[j - 1];
                        seq[j - 1] = tmp;
                        resultList.Add(j);
                    }
                }
            }

            Console.WriteLine(resultList.Count);
            resultList.ForEach(i => Console.WriteLine($"{i} {i + 1}"));
            Console.ReadLine();
        }
    }
}
0