結果
| 問題 |
No.116 門松列(1)
|
| ユーザー |
|
| 提出日時 | 2020-03-27 00:54:18 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 5,000 ms |
| コード長 | 606 bytes |
| コンパイル時間 | 927 ms |
| コンパイル使用メモリ | 110,872 KB |
| 実行使用メモリ | 40,952 KB |
| 最終ジャッジ日時 | 2025-01-02 07:44:31 |
| 合計ジャッジ時間 | 2,722 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
public class P0116 {
public static void Main() {
var n = int.Parse(Console.ReadLine().Trim());
var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList();
var result = 0;
for(int i=0; i<n-2; i++) {
var cands = new int[a[i], a[i+1], a[i+2]];
if (a[i+1] < a[i] && a[i+1] < a[i+2] && a[i] != a[i+2]) {
result += 1;
} else if(a[i+1] > a[i] && a[i+1] > a[i+2] && a[i] != a[i+2]) {
result += 1;
}
}
Console.WriteLine(result);
}
}