|

General

# Author Problem Lang Verdict Time Memory Sent Judged
79934699 Practice:
rahul__n
1350B - 41 GNU C++17 Wrong answer on test 2 217 ms 11520 KB 2020-05-13 05:20:46 2020-05-13 05:20:46

→ Source
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include <fstream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define pb push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define MAX 100000
using namespace std;
typedef long long int lli;
typedef unsigned long long ULL;
typedef long double LD;

lli t, n;
vector<lli> a(500007);
lli dp[500007];
lli solve(lli x){
if(x <= 0){
return 0;
}
if(dp[x] != -1){
return dp[x];
}
dp[x] = 1;
for(lli i = 1; i <= sqrt(x); i++){
if(x % i == 0){
if(a[i] < a[x] and i != x){
dp[x] = max(dp[x], 1 + solve(i));
}
if(a[x/i] < a[x] and x/i != x){
dp[x] = max(dp[x], 1 + solve(x/i));
}
}
}
dp[x] = max(dp[x], solve(x-1));

return dp[x];
}
int main(){
cin >> t;

while(t--){

MS1(dp);
cin >> n;
for(lli i = 1; i <= n; i++){
cin >> a[i];
}
cout << solve(n) << endl;
}
}

?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
?
?
?