結果

問題 No.1053 ゲーミング棒
ユーザー keymoonkeymoon
提出日時 2020-05-15 21:28:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,042 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 110,648 KB
実行使用メモリ 37,384 KB
最終ジャッジ日時 2023-10-19 13:07:22
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
26,468 KB
testcase_01 AC 32 ms
26,412 KB
testcase_02 AC 35 ms
26,472 KB
testcase_03 AC 32 ms
26,420 KB
testcase_04 AC 32 ms
26,416 KB
testcase_05 AC 32 ms
26,412 KB
testcase_06 AC 32 ms
26,412 KB
testcase_07 AC 32 ms
26,412 KB
testcase_08 AC 35 ms
26,468 KB
testcase_09 AC 32 ms
26,412 KB
testcase_10 AC 32 ms
26,412 KB
testcase_11 AC 32 ms
26,416 KB
testcase_12 AC 33 ms
26,416 KB
testcase_13 AC 33 ms
26,420 KB
testcase_14 AC 32 ms
26,412 KB
testcase_15 AC 33 ms
26,416 KB
testcase_16 AC 32 ms
26,412 KB
testcase_17 AC 35 ms
26,468 KB
testcase_18 AC 32 ms
26,416 KB
testcase_19 AC 32 ms
26,412 KB
testcase_20 AC 32 ms
26,412 KB
testcase_21 AC 32 ms
26,412 KB
testcase_22 AC 35 ms
26,468 KB
testcase_23 AC 75 ms
36,396 KB
testcase_24 AC 77 ms
36,396 KB
testcase_25 AC 84 ms
37,384 KB
testcase_26 AC 77 ms
36,400 KB
testcase_27 AC 33 ms
26,372 KB
testcase_28 AC 32 ms
26,412 KB
testcase_29 AC 33 ms
26,372 KB
testcase_30 AC 61 ms
30,728 KB
testcase_31 AC 64 ms
31,288 KB
testcase_32 AC 64 ms
30,832 KB
testcase_33 AC 64 ms
31,344 KB
testcase_34 AC 65 ms
31,292 KB
testcase_35 AC 69 ms
32,356 KB
testcase_36 AC 70 ms
32,464 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(0);
            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