結果

問題 No.482 あなたの名は
ユーザー 14番14番
提出日時 2017-02-12 01:59:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 1,987 bytes
コンパイル時間 3,838 ms
コンパイル使用メモリ 108,260 KB
実行使用メモリ 59,952 KB
最終ジャッジ日時 2023-08-28 16:21:43
合計ジャッジ時間 7,227 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,964 KB
testcase_01 AC 61 ms
22,032 KB
testcase_02 AC 61 ms
21,992 KB
testcase_03 AC 60 ms
20,012 KB
testcase_04 AC 60 ms
21,920 KB
testcase_05 AC 61 ms
23,976 KB
testcase_06 AC 61 ms
24,048 KB
testcase_07 AC 69 ms
22,224 KB
testcase_08 AC 69 ms
22,128 KB
testcase_09 AC 68 ms
24,188 KB
testcase_10 AC 69 ms
22,108 KB
testcase_11 AC 68 ms
22,112 KB
testcase_12 AC 69 ms
24,140 KB
testcase_13 AC 69 ms
22,104 KB
testcase_14 AC 69 ms
22,088 KB
testcase_15 AC 181 ms
59,876 KB
testcase_16 AC 181 ms
57,988 KB
testcase_17 AC 181 ms
57,872 KB
testcase_18 AC 182 ms
56,424 KB
testcase_19 AC 182 ms
57,980 KB
testcase_20 AC 182 ms
57,216 KB
testcase_21 AC 182 ms
55,896 KB
testcase_22 AC 179 ms
56,464 KB
testcase_23 AC 184 ms
59,952 KB
testcase_24 AC 182 ms
57,232 KB
testcase_25 AC 182 ms
57,868 KB
testcase_26 AC 182 ms
58,344 KB
testcase_27 AC 182 ms
57,896 KB
testcase_28 AC 184 ms
57,856 KB
testcase_29 AC 179 ms
59,912 KB
testcase_30 AC 61 ms
22,072 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.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        bool ans = this.GetAns();
        Console.WriteLine(ans?"YES":"NO");
    }

    private bool GetAns() {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
        int itemCount = (int)inpt[0];
        long nokori = inpt[1];

        int[] items = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();

        Dictionary<int, int> numIndex = new Dictionary<int, int>();
        Dictionary<int, int> indexNum = new Dictionary<int, int>();

        for(int i=0; i<items.Length; i++) {
            indexNum.Add(i, items[i]);
            numIndex.Add(items[i], i);
        }

        for(int i=1; i<=itemCount; i++) {
            if(items[i-1] == i) {
                continue;
            }
            if(nokori <= 0) {
                return false;
            }
            int idx = numIndex[i];
            int num = items[i-1];

            items[i-1] = items[idx];
            items[idx] = num;

            numIndex[i] = i-1;
            numIndex[num] = idx;
            indexNum[i-1] = i;
            indexNum[idx] = num;
            nokori--;
        }

        return nokori%2==0;
    }




    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"







";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0