結果
問題 |
No.390 最長の数列
|
ユーザー |
|
提出日時 | 2017-08-01 23:11:58 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,004 bytes |
コンパイル時間 | 827 ms |
コンパイル使用メモリ | 90,236 KB |
実行使用メモリ | 54,400 KB |
最終ジャッジ日時 | 2024-10-11 00:28:24 |
合計ジャッジ時間 | 3,844 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 WA * 5 |
ソースコード
#include<cstdio> #include<iostream> #include<algorithm> #include<string> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<set> #include<numeric> #include<limits> #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ll, string> pls; #define MAX_N 1000000 int n; int a[100010]; int used[MAX_N]; map<int, int> m; int main() { cin >> n; int mx = 0; for (int i = 0; i < n; i++) { cin >> a[i]; m[a[i]] = 1; mx = max(mx,a[i]); } sort(a, a + n); int num, num_mx = 0,x; for (int i = 0; i < n - num_mx; i++) { if (a[i] == 1)continue; if (used[a[i]])continue; x = a[i]; num = 0; for (int j = 1; x * j <= mx; j++) { if (m[x * j]) { used[x*j] = 1; num++; x = x*j; j = 1; } } num_mx = max(num_mx, num); } if (a[0] == 1)num_mx++; cout << num_mx << endl; return 0; }