daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top