結果
問題 |
No.1053 ゲーミング棒
|
ユーザー |
![]() |
提出日時 | 2020-06-28 12:17:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 1,950 bytes |
コンパイル時間 | 1,554 ms |
コンパイル使用メモリ | 106,112 KB |
実行使用メモリ | 32,512 KB |
最終ジャッジ日時 | 2024-07-07 11:48:01 |
合計ジャッジ時間 | 4,236 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; namespace Problem1053 { class Program { static void Main(string[] args) { int N = GetInt(); var A = GetIntArray(); var list = new List<int>(); int temp = 0; for(int i = 0; i < N; i++) { if(temp != A[i]) { list.Add(A[i]); temp = A[i]; } } var set = new HashSet<int>(); if(list.Count == 1) { Console.WriteLine(0); return; } if(list[0] == list[list.Count - 1]) { list.RemoveAt(list.Count - 1); foreach(var value in list) { if(!set.Add(value)) { Console.WriteLine(-1); return; } } Console.WriteLine(1); } else { foreach (var value in list) { if (!set.Add(value)) { Console.WriteLine(-1); return; } } Console.WriteLine(0); } } public static int GetInt() => int.Parse(Console.ReadLine()); public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray(); public static double GetDouble() => double.Parse(Console.ReadLine()); public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray(); public static long GetLong() => long.Parse(Console.ReadLine()); public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray(); } }