結果
| 問題 |
No.1053 ゲーミング棒
|
| コンテスト | |
| ユーザー |
Yusei Kato
|
| 提出日時 | 2020-06-28 12:15:31 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,828 bytes |
| コンパイル時間 | 3,011 ms |
| コンパイル使用メモリ | 105,600 KB |
| 実行使用メモリ | 32,512 KB |
| 最終ジャッジ日時 | 2024-07-07 11:40:46 |
| 合計ジャッジ時間 | 5,364 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 3 |
コンパイルメッセージ
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[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();
}
}
Yusei Kato