結果

問題 No.390 最長の数列
ユーザー snukesnuke
提出日時 2016-07-08 22:28:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,339 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 118,760 KB
最終ジャッジ日時 2024-04-21 05:55:20
合計ジャッジ時間 55,318 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,713 ms
117,636 KB
testcase_01 AC 1,705 ms
117,732 KB
testcase_02 WA -
testcase_03 AC 1,761 ms
117,752 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 1,785 ms
117,836 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 1,866 ms
117,760 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:68:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   68 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
main.cpp:69:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   69 |   rep(i,n) scanf("%d",&a[i]);
      |            ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}

const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int n;
int a[MX];
int dp[MX];
vi p[MX*10];

int main() {
  scanf("%d",&n);
  rep(i,n) scanf("%d",&a[i]);
  int ans = 0;
  rrep(i,MX*10-4) {
    for (int j = i+i; j < MX*10; j += i) p[j].pb(i);
  }
  rep(i,n) {
    int now = 0;
    for (int x : p[a[i]]) {
      maxs(now, dp[x]);
    }
    ++now;
    dp[a[i]] = now;
    maxs(ans, now);
  }
  cout<<ans<<endl;
  return 0;
}





0