結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
Xelmeph
|
| 提出日時 | 2016-07-08 23:33:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,329 bytes |
| コンパイル時間 | 680 ms |
| コンパイル使用メモリ | 80,788 KB |
| 実行使用メモリ | 13,632 KB |
| 最終ジャッジ日時 | 2024-10-13 07:16:37 |
| 合計ジャッジ時間 | 7,277 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 TLE * 1 -- * 13 |
ソースコード
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r) for(int i = l; i < r; i++)
#define RFOR(i, l,r) for(int i= (l)-1; i>= (r) ; i--)
constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;
int solve(vector<int>& p)
{
vector< vector<int> > s(p.size());
REP(i, p.size())
{
REP(j, p.size())
if(p[j] % p[i] == 0)
s[i].push_back(j);
}
vector<int> high(s.size(), 1);
RREP(i, s.size())
{
int higher = 1;
RREP(j, s[i].size())
{
if(s[s[i][j]].size())
{
int tmp = 1 + high[s[i][j]];
higher = higher > tmp ? higher : tmp;
}
}
high[i] = higher;
}
return *max_element(high.begin(), high.end());
}
int main()
{
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> p;
REP(i, n)
{
int tmp;
cin >> tmp;
p.push_back(tmp);
}
sort(p.begin(),p.end());
cout << solve(p) -1 << '\n';
}
Xelmeph