Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4.  
  5. public class VozrPosl {
  6.  
  7.     public static void main(String[] args) throws FileNotFoundException {
  8.        
  9.         Scanner sc = new Scanner(System.in);
  10.         int N = sc.nextInt();
  11.        
  12.         int[] arr = new int[N];
  13.         for(int i = 0; i < N; i++) {
  14.             arr[i] = sc.nextInt();
  15.         }
  16.        
  17.         int Answer[] = new int[N];
  18.        
  19.         int Max = 0;
  20.        
  21.         for(int i = 0; i < N; i++) {
  22.             Answer[i] = 1;
  23.             for(int j = 0; j < i; j++) {
  24.                 if(arr[i] > arr[j] && Answer[j] + 1 > Answer[i]) {
  25.                     Answer[i] = Answer[j] + 1;
  26.                 }
  27.             }
  28.             Max = Math.max(Answer[i], Max);
  29.         }
  30.        
  31.         System.out.println(Max);
  32.        
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement