結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2016-07-16 16:48:26 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,041 bytes |
| コンパイル時間 | 3,799 ms |
| コンパイル使用メモリ | 82,032 KB |
| 実行使用メモリ | 52,804 KB |
| 最終ジャッジ日時 | 2024-10-15 13:48:07 |
| 合計ジャッジ時間 | 10,551 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 WA * 1 RE * 10 |
ソースコード
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;
public class No0390 {
static final Scanner in = new Scanner(System.in);
static final PrintWriter out = new PrintWriter(System.out,false);
static boolean debug = false;
static void solve() {
int n = in.nextInt();
int[] a = new int[n];
for (int i=0; i<n; i++) {
a[i] = in.nextInt();
}
int MAX = 1000001;
int[] dp = new int[MAX];
for (int x : a) {
dp[x] = 1;
}
int ans = 1;
for (int i=0; i<MAX; i++) {
if (dp[i] == 0) continue;
for (int j=i+i; j*j<MAX; j+=i) {
if (dp[j] != 0) {
dp[j] = Math.max(dp[i] + 1, dp[j]);
}
}
ans = Math.max(ans, dp[i]);
}
out.println(ans);
}
public static void main(String[] args) {
debug = args.length > 0;
long start = System.nanoTime();
solve();
out.flush();
long end = System.nanoTime();
dump((end - start) / 1000000 + " ms");
in.close();
out.close();
}
static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}
t8m8⛄️