結果

問題 No.1053 ゲーミング棒
ユーザー keymoonkeymoon
提出日時 2020-05-15 21:27:47
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,044 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 110,784 KB
実行使用メモリ 37,456 KB
最終ジャッジ日時 2023-10-19 13:05:56
合計ジャッジ時間 3,693 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
26,592 KB
testcase_01 AC 31 ms
26,536 KB
testcase_02 AC 34 ms
26,596 KB
testcase_03 AC 33 ms
26,544 KB
testcase_04 AC 32 ms
26,540 KB
testcase_05 AC 33 ms
26,536 KB
testcase_06 AC 32 ms
26,536 KB
testcase_07 AC 32 ms
26,536 KB
testcase_08 AC 34 ms
26,592 KB
testcase_09 AC 33 ms
26,536 KB
testcase_10 AC 33 ms
26,536 KB
testcase_11 AC 34 ms
26,540 KB
testcase_12 AC 32 ms
26,540 KB
testcase_13 AC 32 ms
26,544 KB
testcase_14 AC 32 ms
26,536 KB
testcase_15 AC 32 ms
26,540 KB
testcase_16 AC 32 ms
26,536 KB
testcase_17 AC 35 ms
26,592 KB
testcase_18 AC 32 ms
26,540 KB
testcase_19 AC 32 ms
26,536 KB
testcase_20 AC 32 ms
26,536 KB
testcase_21 AC 32 ms
26,536 KB
testcase_22 AC 35 ms
26,592 KB
testcase_23 AC 74 ms
36,468 KB
testcase_24 AC 76 ms
36,468 KB
testcase_25 AC 82 ms
37,456 KB
testcase_26 AC 76 ms
36,472 KB
testcase_27 WA -
testcase_28 AC 31 ms
26,536 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 64 ms
31,360 KB
testcase_32 AC 64 ms
30,904 KB
testcase_33 AC 64 ms
31,416 KB
testcase_34 AC 65 ms
31,364 KB
testcase_35 AC 69 ms
32,428 KB
testcase_36 AC 69 ms
32,536 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.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        int res = 0;
        if (a.First() == a.Last())
        {
            res++;
            a = a.SkipWhile(x => a[0] == x).ToArray();
        }
        if (a.Length == 0)
        {
            Console.WriteLine(res);
            return;
        }
        var set = new HashSet<int>() { a[0] };
        var last = a[0];
        for (int i = 1; i < a.Length; i++)
        {
            if (last != a[i] && !set.Add(a[i]))
            {
                Console.WriteLine(-1);
                return;
            }
            last = a[i];
        }
        Console.WriteLine(res);
    }
}
0