結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2017-05-16 09:28:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 961 bytes |
コンパイル時間 | 977 ms |
コンパイル使用メモリ | 114,408 KB |
実行使用メモリ | 19,328 KB |
最終ジャッジ日時 | 2024-06-25 01:28:40 |
合計ジャッジ時間 | 2,585 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); int[] kadomatsu = new int[3]; int kadomatsuCnt = 0; bool isRandom = true; for (int i = 0; i < N - 2; i++) { isRandom = true; kadomatsu = new int[3]; for (int j = 0; j < 3; j++) { kadomatsu[j] = A[i + j]; if (kadomatsu.Count(x => x == kadomatsu[j]) > 1) { isRandom = !isRandom; break; } } if (!isRandom) { continue; } Array.Sort(kadomatsu); if (kadomatsu[kadomatsu.Length - 2] == A[i + 1]) { continue; } kadomatsuCnt++; } Console.WriteLine(kadomatsuCnt); } }