Codeforces Round 641 (Div. 2) 1350B - Orac and Models Solution
Problem Link : https://codeforces.com/problemset/problem/1350/B
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n ;
- cin >> n ;
- int a[n+2] , dp[n+2] ;
- for ( int i = 1 ; i <= n ; i++ ) {
- cin >> a[i] ;
- dp[i] = 1 ;
- }
- int ans = 1;
- for ( int i = 1 ; i <= n ; i++ ) {
- for ( int j = i*2 ; j <= n ; j+=i ){
- if ( a[i] < a[j] ){
- dp[j] = max ( dp[j] , dp[i] + 1 ) ;
- ans = max ( ans , dp[j] ) ;
- }
- }
- }
- cout << ans <<"\n" ;
- }
- }
No comments