結果

問題 No.390 最長の数列
ユーザー mbanmban
提出日時 2016-10-31 08:48:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 895 bytes
コンパイル時間 2,827 ms
コンパイル使用メモリ 111,684 KB
実行使用メモリ 37,984 KB
最終ジャッジ日時 2024-04-10 10:13:07
合計ジャッジ時間 3,332 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
27,520 KB
testcase_01 AC 28 ms
25,120 KB
testcase_02 AC 29 ms
23,340 KB
testcase_03 AC 28 ms
25,376 KB
testcase_04 AC 29 ms
25,228 KB
testcase_05 AC 106 ms
35,840 KB
testcase_06 AC 139 ms
37,768 KB
testcase_07 AC 28 ms
27,224 KB
testcase_08 AC 46 ms
28,384 KB
testcase_09 AC 52 ms
30,412 KB
testcase_10 AC 114 ms
37,984 KB
testcase_11 AC 112 ms
36,064 KB
testcase_12 AC 107 ms
35,864 KB
testcase_13 AC 91 ms
34,780 KB
testcase_14 AC 90 ms
32,340 KB
testcase_15 AC 27 ms
23,056 KB
testcase_16 AC 51 ms
30,592 KB
testcase_17 AC 57 ms
31,188 KB
testcase_18 AC 57 ms
29,136 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;

class Magatro
{
    
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        Array.Sort(x);
        int A = x.Max();
        int[] dp = (new int[A+1]).Select(q=>-1).ToArray();
        for(int i = 0; i < N; i++)
        {
            dp[x[i]] = 1;

        }

        for(int i = 1; i <= A; i++)
        {
            if (dp[i] == -1)
            {
                continue;
            }
            for(int j = i + i; j <= A; j += i)
            {
                if (dp[j] != -1)
                {
                    dp[j] = Math.Max(dp[i] + 1, dp[j]);

                    
                }
            }
        }
        Console.Write(dp.Max());

    }

}


0