|
|
вернуться в форумWA15 Why WA 15? Help me please. import java.util.Arrays; import java.util.Scanner; public class Timus1579 { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n=in.nextInt(),r=in.nextInt(); Shub[] a=new Shub[n]; Xod[] x=new Xod[n]; int ix=1,im=0,gt=0; a[0]=new Shub(in.nextInt(),0); x[0]=new Xod(a[0].size); for(int i=1; i<n; i++){ a[i]=new Shub(in.nextInt(),i); if(x[im].size+r<a[i].size){ x[im].size=a[i].size; x[im].amount++; a[i].num=im; im=(im+1)%ix; }else{ a[i].num=ix; x[ix]=new Xod(a[i].size); ix++; } } System.out.println(ix); Arrays.sort(a); for(int i=0; i<ix; i++){ System.out.print(x[i].amount+" "); while((gt<n)&& (a[gt].num==i)){ System.out.print((a[gt].num2+1)+" "); gt++; } System.out.println(); } } } class Shub implements Comparable{ int num,num2,size; public Shub(int s, int n) { num=0; size=s; num2=n; } public int compareTo(Object o) { Shub a=(Shub)o; if(num==a.num){ return num2-a.num2; }else return num-a.num; } } class Xod{ int size,amount; public Xod(int i) { size=i; amount=1; } } |
|
|