結果

問題 No.116 門松列(1)
ユーザー kmtrc130kmtrc130
提出日時 2017-05-16 09:28:14
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 961 bytes
コンパイル時間 2,388 ms
コンパイル使用メモリ 107,112 KB
実行使用メモリ 23,708 KB
最終ジャッジ日時 2023-09-07 07:10:31
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
23,640 KB
testcase_01 AC 63 ms
21,776 KB
testcase_02 AC 64 ms
21,644 KB
testcase_03 AC 64 ms
21,652 KB
testcase_04 AC 61 ms
21,612 KB
testcase_05 AC 63 ms
23,708 KB
testcase_06 AC 63 ms
23,560 KB
testcase_07 AC 64 ms
21,600 KB
testcase_08 AC 63 ms
19,600 KB
testcase_09 AC 63 ms
23,652 KB
testcase_10 AC 64 ms
21,752 KB
testcase_11 AC 64 ms
19,700 KB
testcase_12 AC 64 ms
21,580 KB
testcase_13 AC 64 ms
21,652 KB
testcase_14 AC 64 ms
19,688 KB
testcase_15 AC 64 ms
21,600 KB
testcase_16 AC 65 ms
21,620 KB
testcase_17 AC 63 ms
19,616 KB
testcase_18 AC 64 ms
21,708 KB
testcase_19 AC 65 ms
23,636 KB
testcase_20 AC 64 ms
21,640 KB
testcase_21 AC 63 ms
21,660 KB
testcase_22 AC 63 ms
21,772 KB
testcase_23 AC 63 ms
21,684 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;

class Program
{
    static void Main(string[] args)
    {
        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);
    }
}
0