結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,864 KB
testcase_01 AC 56 ms
20,768 KB
testcase_02 AC 56 ms
20,828 KB
testcase_03 AC 56 ms
22,764 KB
testcase_04 AC 56 ms
22,916 KB
testcase_05 AC 56 ms
22,808 KB
testcase_06 AC 56 ms
20,928 KB
testcase_07 AC 64 ms
22,800 KB
testcase_08 WA -
testcase_09 AC 63 ms
22,844 KB
testcase_10 AC 64 ms
20,828 KB
testcase_11 AC 63 ms
20,816 KB
testcase_12 WA -
testcase_13 AC 65 ms
20,880 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 127 ms
39,976 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 126 ms
37,956 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 127 ms
35,788 KB
testcase_24 AC 127 ms
35,964 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = int.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 (int 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