結果
問題 |
No.2218 Multiple LIS
|
ユーザー |
|
提出日時 | 2023-08-26 19:49:52 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 290 ms / 3,000 ms |
コード長 | 955 bytes |
コンパイル時間 | 2,343 ms |
コンパイル使用メモリ | 106,240 KB |
実行使用メモリ | 32,640 KB |
最終ジャッジ日時 | 2024-12-25 21:30:30 |
合計ジャッジ時間 | 8,154 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var dp = new int[100001]; foreach (var ai in a) { var max = 0; foreach (var d in Divs(ai)) max = Math.Max(max, dp[d]); dp[ai] = Math.Max(dp[ai], max + 1); } WriteLine(dp.Max()); } static List<int> Divs(int n) { var ans = new List<int>(); for (var i = 1; i * i <= n; ++i) { if (n % i == 0) { ans.Add(i); if (i * i < n) ans.Add(n / i); } } return ans; } }