結果

問題 No.921 ずんだアロー
ユーザー tsushimatsushima
提出日時 2019-11-08 21:47:32
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,301 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 68,208 KB
実行使用メモリ 30,280 KB
最終ジャッジ日時 2023-10-13 03:45:33
合計ジャッジ時間 4,273 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,644 KB
testcase_01 AC 61 ms
23,764 KB
testcase_02 AC 61 ms
23,708 KB
testcase_03 AC 61 ms
21,700 KB
testcase_04 AC 61 ms
21,548 KB
testcase_05 WA -
testcase_06 AC 68 ms
21,976 KB
testcase_07 AC 68 ms
21,712 KB
testcase_08 AC 61 ms
21,732 KB
testcase_09 AC 62 ms
21,604 KB
testcase_10 AC 99 ms
28,704 KB
testcase_11 WA -
testcase_12 AC 75 ms
24,828 KB
testcase_13 AC 92 ms
29,848 KB
testcase_14 AC 96 ms
30,280 KB
testcase_15 AC 83 ms
23,996 KB
testcase_16 AC 70 ms
22,152 KB
testcase_17 AC 95 ms
28,200 KB
testcase_18 AC 100 ms
30,000 KB
testcase_19 AC 100 ms
29,972 KB
testcase_20 AC 99 ms
27,936 KB
testcase_21 AC 99 ms
27,864 KB
testcase_22 AC 100 ms
29,880 KB
testcase_23 AC 102 ms
28,872 KB
testcase_24 AC 100 ms
29,904 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;
            foreach (var data in continuous)
            {
                if (data > 1)
                {
                    if (!graterOne) total++;
                    total += data - 1;
                    graterOne = true;
                }
                else
                {
                    graterOne = false;
                }
            }

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