結果

問題 No.390 最長の数列
ユーザー mbanmban
提出日時 2016-09-26 21:47:50
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,056 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 114,396 KB
実行使用メモリ 56,988 KB
最終ジャッジ日時 2024-05-01 05:35:21
合計ジャッジ時間 7,904 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
56,988 KB
testcase_01 AC 29 ms
25,260 KB
testcase_02 AC 30 ms
27,340 KB
testcase_03 AC 30 ms
24,988 KB
testcase_04 AC 29 ms
25,248 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro {
    static int N = int.Parse(Console.ReadLine());
    static int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    static void Main() {
        Array.Sort(x);
        int[] dp = new int[N + 1];
        for(int i = 0; i <= N; i++) {
            if (i == 0) {
                dp[i] = 0;
                continue;
            }
            bool a = true;
            int max = 0;
            for (int j = 0; j <=i-2; j++) {
                
                if (x[i - 1] % x[j] == 0) {
                    max = Math.Max(max, dp[j + 1]);
                    a = false;
                   
                }
                
            }
            if (a) {
                dp[i] = 1;
            }
            else {
                dp[i] = max + 1;
            }
        }

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

    

}
0