結果

問題 No.116 門松列(1)
ユーザー NoNo
提出日時 2015-06-25 00:49:18
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 1,355 bytes
コンパイル時間 5,320 ms
コンパイル使用メモリ 101,988 KB
実行使用メモリ 24,788 KB
最終ジャッジ日時 2023-09-07 06:45:17
合計ジャッジ時間 6,393 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,620 KB
testcase_01 AC 59 ms
20,724 KB
testcase_02 AC 59 ms
20,700 KB
testcase_03 AC 58 ms
20,852 KB
testcase_04 AC 58 ms
20,648 KB
testcase_05 AC 59 ms
20,712 KB
testcase_06 AC 59 ms
24,788 KB
testcase_07 AC 59 ms
20,704 KB
testcase_08 AC 58 ms
20,760 KB
testcase_09 AC 58 ms
22,664 KB
testcase_10 AC 58 ms
20,656 KB
testcase_11 AC 59 ms
22,672 KB
testcase_12 AC 59 ms
20,660 KB
testcase_13 AC 60 ms
20,708 KB
testcase_14 AC 60 ms
20,836 KB
testcase_15 AC 58 ms
20,712 KB
testcase_16 AC 61 ms
20,828 KB
testcase_17 AC 59 ms
20,772 KB
testcase_18 AC 59 ms
20,704 KB
testcase_19 AC 59 ms
22,668 KB
testcase_20 AC 58 ms
20,776 KB
testcase_21 AC 59 ms
20,652 KB
testcase_22 AC 59 ms
22,664 KB
testcase_23 AC 63 ms
20,644 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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace foryuki
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = ConvertStringArrayToIntArray(Console.ReadLine().Split());
            int cnt = 0;

            for (int i = 0; i < n - 2; i++)
            {
                if (a[i] == a[i + 1] || a[i] == a[i + 2] || a[i + 1] == a[i + 2])
                {
                    continue;
                }
                if (a[i] < a[i + 1] && a[i + 1] < a[i + 2])
                {
                    continue;
                }
                if (a[i] > a[i + 1] && a[i + 1] > a[i + 2])
                {
                    continue;
                }

                cnt++;
            }

            Console.WriteLine(cnt);
        }

        //-------------------------------------------------------------

        static int[] ConvertStringArrayToIntArray(string[] array)
        {
            return Array.ConvertAll(array, str => int.Parse(str));
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str) list.Add(int.Parse(c));
            return list;
        }
    }
}
0