Skip to content

Commit e1f48a2

Browse files
Orac and Models
1 parent 2d83034 commit e1f48a2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

1350/B/Main.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.util.Arrays;
2+
import java.util.Scanner;
3+
4+
public class Main {
5+
public static void main(String[] args) {
6+
Scanner sc = new Scanner(System.in);
7+
8+
int t = sc.nextInt();
9+
for (int tc = 0; tc < t; ++tc) {
10+
int n = sc.nextInt();
11+
int[] s = new int[n];
12+
for (int i = 0; i < s.length; ++i) {
13+
s[i] = sc.nextInt();
14+
}
15+
16+
System.out.println(solve(s));
17+
}
18+
19+
sc.close();
20+
}
21+
22+
static int solve(int[] s) {
23+
int[] maxLengths = new int[s.length];
24+
Arrays.fill(maxLengths, 1);
25+
26+
for (int i = 0; i < maxLengths.length; ++i) {
27+
for (int j = i * 2 + 1; j < maxLengths.length; j += i + 1) {
28+
if (s[j] > s[i]) {
29+
maxLengths[j] = Math.max(maxLengths[j], maxLengths[i] + 1);
30+
}
31+
}
32+
}
33+
34+
return Arrays.stream(maxLengths).max().getAsInt();
35+
}
36+
}

0 commit comments

Comments
 (0)