結果

問題 No.482 あなたの名は
ユーザー bluemeganebluemegane
提出日時 2018-09-14 20:48:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 105,116 KB
実行使用メモリ 42,140 KB
最終ジャッジ日時 2023-09-20 10:06:18
合計ジャッジ時間 6,636 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
22,920 KB
testcase_01 AC 57 ms
20,896 KB
testcase_02 AC 57 ms
18,808 KB
testcase_03 AC 56 ms
20,844 KB
testcase_04 AC 57 ms
20,840 KB
testcase_05 AC 56 ms
22,740 KB
testcase_06 AC 56 ms
20,688 KB
testcase_07 AC 64 ms
20,872 KB
testcase_08 AC 65 ms
21,000 KB
testcase_09 AC 63 ms
20,956 KB
testcase_10 AC 64 ms
22,972 KB
testcase_11 AC 64 ms
20,988 KB
testcase_12 AC 63 ms
20,920 KB
testcase_13 AC 64 ms
20,796 KB
testcase_14 AC 63 ms
20,972 KB
testcase_15 AC 127 ms
38,036 KB
testcase_16 AC 127 ms
40,092 KB
testcase_17 AC 128 ms
39,956 KB
testcase_18 AC 127 ms
37,912 KB
testcase_19 AC 127 ms
36,068 KB
testcase_20 AC 128 ms
40,044 KB
testcase_21 AC 129 ms
37,968 KB
testcase_22 AC 128 ms
40,020 KB
testcase_23 AC 129 ms
38,028 KB
testcase_24 AC 129 ms
37,928 KB
testcase_25 AC 128 ms
37,928 KB
testcase_26 AC 130 ms
42,140 KB
testcase_27 AC 129 ms
37,904 KB
testcase_28 AC 128 ms
37,904 KB
testcase_29 AC 128 ms
36,096 KB
testcase_30 AC 56 ms
18,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = long.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        var change = true;
        while (change)
        {
            change = false;
            for (int i = 0; i < n; i++)
                if (a[i] != i + 1)
                {
                    swap(a, i, a[i] - 1);
                    count++;
                    change = true;
                }
        }
        Console.WriteLine(check(k, count) ? "YES" : "NO");
    }
    public static bool check(long k, int count)
    {
        if (count > k) return false;
        if ((k - count) % 2 == 0) return true;
        else return false;
    }

    public static void swap(int[] a, int p, int q)
    {
        var t = a[p];
        a[p] = a[q];
        a[q] = t;
    }
}
0