Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LDS {
- private static int najdolgaOpagackaSekvenca(int nums[]) {
- if (nums == null || nums.length == 0) {
- return 0;
- }
- int max[] = new int[nums.length];
- for (int i = 0; i < nums.length; i++) {
- max[i] = 1;
- for (int j = 0; j < i; j++) {
- if (nums[i] < nums[j]) {
- max[i] = Math.max(max[i], max[j] + 1);
- }
- }
- }
- return max[max.length - 1];
- }
- public static void main(String[] args) {
- Scanner stdin = new Scanner(System.in);
- int n = stdin.nextInt();
- int a[] = new int[n];
- for (int i = 0; i < a.length; i++) {
- a[i] = stdin.nextInt();
- }
- System.out.println(najdolgaOpagackaSekvenca(a));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement