結果

問題 No.482 あなたの名は
ユーザー bluemeganebluemegane
提出日時 2018-09-14 20:42:09
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 104,160 KB
実行使用メモリ 44,100 KB
最終ジャッジ日時 2023-09-20 09:52:08
合計ジャッジ時間 6,670 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
18,732 KB
testcase_01 AC 59 ms
22,808 KB
testcase_02 AC 59 ms
22,804 KB
testcase_03 AC 59 ms
22,748 KB
testcase_04 AC 58 ms
20,756 KB
testcase_05 AC 59 ms
20,808 KB
testcase_06 AC 58 ms
18,816 KB
testcase_07 AC 67 ms
20,864 KB
testcase_08 WA -
testcase_09 AC 67 ms
20,956 KB
testcase_10 AC 67 ms
21,080 KB
testcase_11 AC 67 ms
20,924 KB
testcase_12 WA -
testcase_13 AC 68 ms
20,976 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 129 ms
38,056 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 130 ms
37,956 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 131 ms
37,944 KB
testcase_24 AC 129 ms
37,904 KB
testcase_25 AC 130 ms
40,044 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 127 ms
37,928 KB
testcase_29 AC 127 ms
37,888 KB
testcase_30 AC 58 ms
20,876 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;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != i  + 1)
            {
                swap(a, i, a[i] -1);
                count++;
            }
        }
        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