結果
問題 | No.390 最長の数列 |
ユーザー | tkmst201 |
提出日時 | 2017-04-07 22:04:57 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 887 bytes |
コンパイル時間 | 2,184 ms |
コンパイル使用メモリ | 146,224 KB |
実行使用メモリ | 8,052 KB |
最終ジャッジ日時 | 2023-09-23 00:08:01 |
合計ジャッジ時間 | 2,918 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
7,336 KB |
testcase_01 | AC | 9 ms
7,308 KB |
testcase_02 | AC | 10 ms
7,400 KB |
testcase_03 | AC | 9 ms
7,328 KB |
testcase_04 | AC | 10 ms
7,336 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 8 ms
7,448 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 31 ms
7,728 KB |
testcase_11 | WA | - |
testcase_12 | AC | 31 ms
7,724 KB |
testcase_13 | AC | 24 ms
7,696 KB |
testcase_14 | AC | 56 ms
7,720 KB |
testcase_15 | AC | 3 ms
4,380 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; } template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, pii> P; const ll INF = 1ll<<29; const ll MOD = 1000000007; const double EPS = 1e-10; int dp[1123456]; int n; int x[112345]; int main() { cin >> n; REP(i, n) scanf("%d", x + i); sort(x, x + n); REP(i, n) { for (int j = 2; j <= 1000000; j++) { if ((ll)x[i] * j > 1000000) break; chmax(dp[x[i] * j], dp[x[i]] + 1); } } int ans = 0; REP(i, 1000001) chmax(ans, dp[i]); cout << ans << endl; return 0; }