結果

問題 No.482 あなたの名は
ユーザー bluemegane
提出日時 2018-09-14 20:42:09
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 112,064 KB
実行使用メモリ 45,480 KB
最終ジャッジ日時 2024-07-06 05:26:11
合計ジャッジ時間 4,060 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
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