蓝桥杯 压缩算法

蓝桥杯 压缩算法
class Solution {
public static void main(String[] args) throws IOException {
Scanner a= new Scanner(System.in);
int b=a.nextInt();
int [] c=new int[b];
int d []= new int [b];
int flag = 0;
Set f = new TreeSet();
for(int i=0;i<b;i++) {
c[i]=a.nextInt();
}
d[0]=-c[0];
for(int i=1;i<b;i++) {
flag=0;
for(int j=i-1;j>=0;j–) {
if(c[i](c[j])) {
for(int x=j+1;x<i;x++) {
f.add(c[x]);
}
d[i]=f.size();
flag=1;
}
if(flag
1) {
break;
}
}
if(flag==0) {
d[i]=-c[i];
}
f.clear();
}
for(int i:d) {
System.out.println(i+" ");
}
}

}

猜你喜欢

转载自blog.csdn.net/LIARRR/article/details/88716544
今日推荐