結果
問題 | No.390 最長の数列 |
ユーザー | 👑 horiesiniti |
提出日時 | 2016-07-20 20:40:24 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,212 ms / 5,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 35,552 KB |
最終ジャッジ日時 | 2024-04-10 09:12:59 |
合計ジャッジ時間 | 5,274 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,816 KB |
testcase_01 | AC | 3 ms
6,944 KB |
testcase_02 | AC | 3 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 435 ms
15,860 KB |
testcase_06 | AC | 1,212 ms
35,552 KB |
testcase_07 | AC | 3 ms
6,940 KB |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | AC | 3 ms
6,944 KB |
testcase_10 | AC | 454 ms
16,632 KB |
testcase_11 | AC | 460 ms
16,760 KB |
testcase_12 | AC | 458 ms
16,764 KB |
testcase_13 | AC | 218 ms
13,536 KB |
testcase_14 | AC | 437 ms
22,268 KB |
testcase_15 | AC | 3 ms
6,944 KB |
testcase_16 | AC | 3 ms
6,944 KB |
testcase_17 | AC | 17 ms
6,940 KB |
testcase_18 | AC | 27 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d",&e); | ~~~~~^~~~~~~~~
ソースコード
#include <iostream> #include <stdio.h> #include <set> #include <vector> #include <algorithm> #include <map> using namespace std; std::vector<int> vec,con[100000],cs; std::map<int,int> ms; int main() { // your code goes here std::set<int> sets; int n; scanf("%d",&n); for(int i=0;i<n;i++){ int e; scanf("%d",&e); vec.push_back(e); sets.insert(e); cs.push_back(0); } std::sort(vec.begin(),vec.end()); for(int i=0;i<n;i++){ ms[vec[i]]=i; } for(int i=0;i<n;i++){ int p=vec[i]; for(int j=1;j*j<=p;j++){ if(p%j==0){ int k=p/j; if((sets.find(j)!=sets.end())&&(j!=p)){ con[ms[j]].push_back(i); } if(k==j)continue; if((sets.find(k)!=sets.end())&&(k!=p)){ con[ms[k]].push_back(i); } } } } int ans=0; for(int i=0;i<n;i++){ for(int j=0;j<con[i].size();j++){ int p=con[i][j]; cs[p]=std::max(cs[p],cs[i]+1); ans=std::max(ans,cs[p]); } } printf("%d\n",ans+1); return 0; }