結果
問題 | No.979 Longest Divisor Sequence |
ユーザー | どらら |
提出日時 | 2020-01-31 23:09:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 970 bytes |
コンパイル時間 | 2,215 ms |
コンパイル使用メモリ | 178,112 KB |
実行使用メモリ | 21,088 KB |
最終ジャッジ日時 | 2023-10-17 12:12:54 |
合計ジャッジ時間 | 5,840 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,216 KB |
testcase_01 | AC | 21 ms
8,516 KB |
testcase_02 | AC | 29 ms
9,308 KB |
testcase_03 | AC | 17 ms
8,064 KB |
testcase_04 | AC | 55 ms
15,552 KB |
testcase_05 | AC | 27 ms
9,044 KB |
testcase_06 | AC | 32 ms
10,100 KB |
testcase_07 | AC | 30 ms
9,308 KB |
testcase_08 | AC | 58 ms
15,552 KB |
testcase_09 | AC | 33 ms
9,836 KB |
testcase_10 | AC | 7 ms
4,448 KB |
testcase_11 | AC | 10 ms
4,972 KB |
testcase_12 | AC | 5 ms
4,348 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(){ int N; cin >> N; vector<int> v; rep(i,N){ int a; cin >> a; v.push_back(a); } unordered_map<int,int> m; int ret = 1; rep(i,N){ if(m.count(v[i]) == 0){ int p = 2; while(p*v[i]<=300000){ if(m.count(p*v[i]) == 0){ m[p*v[i]] = 2; } p++; } }else{ ret = max(ret, m[v[i]]); int p = 2; while(p*v[i]<=300000){ if(m.count(p*v[i]) == 0){ m[p*v[i]] = m[v[i]]+1; }else{ if(m[p*v[i]] < m[v[i]]+1){ m[p*v[i]] = m[v[i]]+1; } } p++; } } } cout << ret << endl; return 0; }