bai J

import java.util.*; public class J { public static void tang(int a[],int n) { int[] l = new int [100]; int lmax; l[0]=1; for(int i=1; i<n;i++) { lmax=0; for(int j=0; j<i; j++) if(a[i]>a[j]) { if(l[j]>lmax) lmax=l[j]; } l[i]=lmax+1; } int temp=0; for(int i =0; i <n; i++) { if(l[i]>temp) temp=l[i]; } System.out.println(temp); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); int[] a= new int [100]; for(int j=0; j<n; j++) { int m =in.nextInt(); for(int i =0; i <m; i++) { a[i]=in.nextInt(); } tang(a,m); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.