結果

問題 No.921 ずんだアロー
ユーザー tsushimatsushima
提出日時 2019-11-08 22:07:40
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,451 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 65,724 KB
実行使用メモリ 30,564 KB
最終ジャッジ日時 2023-10-13 03:53:09
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,620 KB
testcase_01 AC 62 ms
21,724 KB
testcase_02 AC 63 ms
23,788 KB
testcase_03 AC 62 ms
21,644 KB
testcase_04 AC 62 ms
21,620 KB
testcase_05 AC 61 ms
21,760 KB
testcase_06 AC 69 ms
21,736 KB
testcase_07 AC 68 ms
21,764 KB
testcase_08 AC 62 ms
21,584 KB
testcase_09 AC 62 ms
23,708 KB
testcase_10 AC 100 ms
30,564 KB
testcase_11 WA -
testcase_12 AC 77 ms
20,804 KB
testcase_13 AC 93 ms
25,756 KB
testcase_14 AC 98 ms
30,192 KB
testcase_15 AC 86 ms
23,964 KB
testcase_16 AC 71 ms
22,216 KB
testcase_17 AC 97 ms
30,240 KB
testcase_18 AC 101 ms
27,932 KB
testcase_19 AC 102 ms
27,880 KB
testcase_20 AC 102 ms
27,892 KB
testcase_21 AC 102 ms
27,912 KB
testcase_22 AC 101 ms
27,852 KB
testcase_23 AC 104 ms
28,988 KB
testcase_24 AC 100 ms
25,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var div = n / 2;
            if (n % 2 == 1) div++;

            var continuous = new List<int>();
            var cur = a[0];
            var count = 1;
            for (var i = 1; i < n; i++)
            {
                if (cur == a[i])
                    count++;
                else
                {
                    continuous.Add(count);
                    count = 1;
                }

                cur = a[i];
            }
            continuous.Add(count);

            var graterOne = false;
            var total = 0;
            var loop = 1;
           foreach (var data in continuous)
            {
                if (data > 1)
                {
                    if (!graterOne && loop != 2) total++;
                    total += data - 1;
                    graterOne = true;
                }
                else
                {
                    if (loop == 1 || (!graterOne && loop == continuous.Count)) total++;
                    graterOne = false;
                }
                loop++;
            }

            Console.WriteLine(Math.Max(div, total));
        }
    }
}
0