結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-13 23:07:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3,079 ms / 5,000 ms |
| コード長 | 767 bytes |
| コンパイル時間 | 2,269 ms |
| コンパイル使用メモリ | 181,536 KB |
| 実行使用メモリ | 10,088 KB |
| 最終ジャッジ日時 | 2024-07-01 04:33:29 |
| 合計ジャッジ時間 | 8,424 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
signed main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int n; cin >> n;
vector<int> arr;
rep(i,0,n){
int t;
cin >> t;
arr.push_back(t);
}
map<int,int> mp;
rep(i,0,n){
mp[arr[i]] = 1;
}
sort(arr.begin(),arr.end());
for(auto e:arr){
int i = 2;
int t = mp[e];
while(e*i < 1e6+1){
if(mp.find(e*i) != mp.end()){
mp[e*i] = max(mp[e*i], t+1);
}
i++;
}
}
int m = 0;
for(auto e:mp){
m = max(m, e.second);
}
cout << m << endl;
}