結果
問題 | No.390 最長の数列 |
ユーザー | daleksprinter |
提出日時 | 2018-09-13 23:07:38 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,938 ms / 5,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 1,730 ms |
コンパイル使用メモリ | 178,952 KB |
実行使用メモリ | 10,316 KB |
最終ジャッジ日時 | 2023-09-13 20:01:34 |
合計ジャッジ時間 | 8,458 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 13 ms
4,376 KB |
testcase_01 | AC | 6 ms
4,376 KB |
testcase_02 | AC | 12 ms
4,384 KB |
testcase_03 | AC | 8 ms
4,380 KB |
testcase_04 | AC | 12 ms
4,380 KB |
testcase_05 | AC | 73 ms
10,112 KB |
testcase_06 | AC | 2,938 ms
10,172 KB |
testcase_07 | AC | 4 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 5 ms
4,380 KB |
testcase_10 | AC | 299 ms
10,108 KB |
testcase_11 | AC | 311 ms
10,104 KB |
testcase_12 | AC | 293 ms
10,168 KB |
testcase_13 | AC | 502 ms
8,728 KB |
testcase_14 | AC | 709 ms
10,316 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 1 ms
4,376 KB |
testcase_17 | AC | 6 ms
4,376 KB |
testcase_18 | AC | 11 ms
4,380 KB |
ソースコード
#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; }