結果
問題 | No.116 門松列(1) |
ユーザー |
![]() |
提出日時 | 2016-09-10 00:36:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 592 bytes |
コンパイル時間 | 1,010 ms |
コンパイル使用メモリ | 109,812 KB |
実行使用メモリ | 27,264 KB |
最終ジャッジ日時 | 2024-06-25 01:21:07 |
合計ジャッジ時間 | 2,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Collections.Generic; using System.Linq; public class Yuki116 { public static void Main() { var n = int.Parse(Console.ReadLine()); var a = Console.ReadLine() .Split(' ') .Select(x => int.Parse(x)) .ToList(); int ans = 0; for(int i = 0; i < n - 2; i++) { ans += Check(a[i], a[i + 1], a[i + 2]); } Console.WriteLine(ans); } public static int Check(int x, int y , int z) { if(x == y|| x == z || y == z) return 0; if(Math.Max(x , Math.Max(y , z)) == y || Math.Min(x , Math.Min(y , z)) == y) return 1; return 0; } }