結果

問題 No.921 ずんだアロー
コンテスト
ユーザー kakel-san
提出日時 2026-01-07 22:52:26
言語 C#
(.NET 10.0.101)
結果
WA  
実行時間 -
コード長 1,056 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,471 ms
コンパイル使用メモリ 167,540 KB
実行使用メモリ 208,524 KB
最終ジャッジ日時 2026-01-07 22:52:39
合計ジャッジ時間 12,992 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (121 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var list = new List<(int ai, int count)>{ (a[0], 1 )};
        for (var i = 1; i < n; ++i)
        {
            if (list[^1].ai == a[i]) list[^1] = (a[i], list[^1].count + 1);
            else list.Add((a[i], 1));
        }
        var dp = new int[list.Count];
        dp[0] = list[0].count;
        if (dp.Length > 1) dp[1] = list[1].count;
        var max = dp[0];
        for (var i = 2; i < dp.Length; ++i)
        {
            dp[i] = max + list[i].count;
            max = Math.Max(max, dp[i - 1]);
        }
        WriteLine(dp.Max());
    }
}
0