結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2016-09-26 21:47:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,056 bytes |
| コンパイル時間 | 892 ms |
| コンパイル使用メモリ | 114,264 KB |
| 実行使用メモリ | 57,316 KB |
| 最終ジャッジ日時 | 2024-11-21 07:01:31 |
| 合計ジャッジ時間 | 44,322 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 TLE * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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());
}
}
mban