結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
![]() |
提出日時 | 2020-01-31 23:01:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,525 bytes |
コンパイル時間 | 1,490 ms |
コンパイル使用メモリ | 175,116 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-09-17 10:05:32 |
合計ジャッジ時間 | 2,426 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template<class T> ostream& operator << (ostream &s, set<T> P) { for(auto it : P) { s << "<" << it << "> "; } return s << endl; } template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) { for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; } const int MAX = 310000; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) cin >> A[i]; int res = 0; vector<int> num(MAX, 0); set<int> alr; for (auto a : A) { chmax(res, num[a] + 1); if (!alr.count(a)) { for (int b = a*2; b < MAX; b += a) { chmax(num[b], num[a] + 1); } } alr.insert(a); } cout << res << endl; }