結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2016-12-15 23:27:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 948 bytes |
コンパイル時間 | 1,526 ms |
コンパイル使用メモリ | 165,696 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-30 08:58:28 |
合計ジャッジ時間 | 4,370 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 3 WA * 1 RE * 11 |
ソースコード
#include <bits/stdc++.h> #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); int n; int xs[112345]; int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) { int a; scanf("%d", &a); xs[a] = 1; } for(int i = 1; i < 1100; ++i) { if( xs[i] == 0 ) continue; for(int j = i + i; j < 100100; j+=i) { if( xs[j] != 0 ) xs[j] = std::max(xs[j], xs[i] + 1); } } int res = -1; for(int i = 0; i < 112345; ++i) { // if( i < 100 ) dumpi(xs[i]); res = std::max(res, xs[i]); } printf("%d\n", res); return 0; }