Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.BufferedWriter;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. import java.io.OutputStreamWriter;
  6.  
  7. public class Main{
  8. public static int max(int a, int b) {
  9. if(a>=b) return a;
  10. else return b;
  11. }
  12. public static void main(String args[]) throws IOException{
  13. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  14. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
  15.  
  16. int cass = Integer.parseInt(br.readLine());
  17. String arr[] = br.readLine().split(" ");
  18. int[] res = new int[cass];
  19. for(int i=0;i<cass;i++) {
  20. res[i] = Integer.parseInt(arr[i]);
  21. }
  22.  
  23. int[] ans = new int[cass];
  24. ans[0] = 1;
  25. int q=1;
  26. for(int i=1;i<cass;i++) {
  27. int max = 1;
  28. for(int j=i-1;j>=0;j--) {
  29. if(res[j]<res[i]&&ans[j]>=max) {
  30. max = ans[j];
  31. ans[i] = max(ans[i],max+1);
  32. }
  33. else ans[i] = max(ans[i],1);
  34. }
  35. q = max(q,ans[i]);
  36. }
  37.  
  38. bw.write(q+"");
  39. bw.flush();
  40. bw.close();
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement