結果

問題 No.116 門松列(1)
ユーザー phsplsphspls
提出日時 2020-03-27 00:54:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 606 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 104,904 KB
実行使用メモリ 37,132 KB
最終ジャッジ日時 2023-08-30 15:55:21
合計ジャッジ時間 5,577 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
33,496 KB
testcase_01 AC 60 ms
21,680 KB
testcase_02 AC 60 ms
19,560 KB
testcase_03 AC 59 ms
21,600 KB
testcase_04 AC 59 ms
21,756 KB
testcase_05 AC 59 ms
19,584 KB
testcase_06 AC 59 ms
19,564 KB
testcase_07 AC 60 ms
23,652 KB
testcase_08 AC 61 ms
23,716 KB
testcase_09 AC 59 ms
23,712 KB
testcase_10 AC 67 ms
30,700 KB
testcase_11 AC 65 ms
26,676 KB
testcase_12 AC 74 ms
36,220 KB
testcase_13 AC 65 ms
28,184 KB
testcase_14 AC 79 ms
37,132 KB
testcase_15 AC 61 ms
22,828 KB
testcase_16 AC 72 ms
33,796 KB
testcase_17 AC 67 ms
30,992 KB
testcase_18 AC 77 ms
31,168 KB
testcase_19 AC 61 ms
21,568 KB
testcase_20 AC 73 ms
30,836 KB
testcase_21 AC 81 ms
35,212 KB
testcase_22 AC 64 ms
27,036 KB
testcase_23 AC 68 ms
25,836 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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);
    }
}
0