Submission #1133495

#TimeUsernameProblemLanguageResultExecution timeMemory
1133495chanononJob Scheduling (CEOI12_jobs)Java
0 / 100
428 ms131072 KiB
import java.util.Scanner; import java.util.Arrays; public class jobs { static int a=0; static int b=0; static int c=0; static int []m; static int[]m2; public static void main(String args[]) { Scanner in=new Scanner(System.in); int in1= in.nextInt(); int in2= in.nextInt(); int in3= in.nextInt(); m=new int[in3]; int[] m1 = Arrays.copyOf(m, m.length); int[] m2 = Arrays.copyOf(m, m.length); Arrays.sort(m1); for(int i=0;i<in3;i++){ m[i]=in.nextInt(); } a=in1; b=in2; c=in3; int []m3=new int[in3]; for(int i=0;i<in3;i++){ m3[i]=sort(m1[i]); } int l=0; int r=in3-1; while(l<r){ int mid=(l+r)/2; if(check(m,mid)==false){ l=1+mid; } else{ r=mid; } } System.out.println(l); for(int j=0;j<in1;j++){ for(int i=0;i<l;i++){ if((i+l*j)<m3.length){System.out.print(m3[i+l*j]+" ");} } System.out.println(0); } } public static boolean check(int []x,int num1){ Arrays.sort(x); for(int i=0;i<c;i++){ x[i]+=b; } for(int i=0;i<c;i++){ x[i]-=(i+num1)/num1; if(i==c-1&&(i+num1)/num1>a){ return false; } } for(int i=0;i<c;i++){ if(x[i]<0){ return false; } } return true; } public static int sort(int o){ for(int i=0;i<c;i++){ if(o==m2[i]){ m2[i]=-1; return m2[i]; } } return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...