結果
問題 |
No.116 門松列(1)
|
ユーザー |
![]() |
提出日時 | 2019-03-18 15:31:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 1,045 bytes |
コンパイル時間 | 881 ms |
コンパイル使用メモリ | 112,312 KB |
実行使用メモリ | 27,448 KB |
最終ジャッジ日時 | 2024-06-25 01:51:03 |
合計ジャッジ時間 | 2,423 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 { public void Solve() { 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); } static void Main() { var solver = new Program(); solver.Solve(); } }