public static int longestIncreasingSubsequence(int[] nums) {
        // write your code here
        int n=nums.length;
        if (nums.length==0)
            return 0;
        int[]A=nums, t=new int[n];
        t[0]=1;
        int rel=1;
        for (int i=1;i<n;++i) {
            t[i]=1;
            for (int j=0;j<i;++j) {
                if (A[i]>=A[j])
                    rel=Math.max(t[i]=Math.max(t[i],t[j]+1),rel);
            }
        }
        return rel;
    }