Submission #607614

# Submission time Handle Problem Language Result Execution time Memory
607614 2022-07-26T21:42:27 Z crystal Job Scheduling (CEOI12_jobs) Java 11
0 / 100
1000 ms 30972 KB
import java.util.*;
import java.lang.*;
import java.io.*;
public class jobs {
static int n,m,d;
static int [] jobs;
  public static void main(String[] args) throws IOException{
    Scanner sc = new Scanner(System.in);

     n =sc.nextInt();
     d =sc.nextInt();
     m =sc.nextInt();
   jobs =new int [m];
    for(int i =0;i<m;i++) {
    	jobs[i]=sc.nextInt();
    }
    Arrays.sort(jobs);
    int l=0;
    int h=jobs[n-1];
    while(l<h) {
    	int mid = (l+h)/2;
    	if(works(mid)) {
    		h=mid;
    	}
    	else {
    		l=mid+1;
    	}
    }
    
    System.out.println(l);

  }
  static boolean works(int mid) {
	  int currday=jobs[0];
	  int machs=0;
	  int i =0;
	  while(i<m) {
		  if(currday>=jobs[i]-1) {
			  
			  if(currday-jobs[i]>d) {
				  return false;
			  }
			  if(machs<mid) {
				  machs++;
				  i++;
			  }
			  else {
				  machs=0;
				  currday++;
				  }
			  
			  
		  }
		  else {
			  currday=jobs[i];
		  }
	  }
return true;
  }
  }






# Verdict Execution time Memory Grader output
1 Incorrect 517 ms 19304 KB Output isn't correct
2 Incorrect 504 ms 18888 KB Output isn't correct
3 Incorrect 518 ms 18964 KB Output isn't correct
4 Incorrect 506 ms 18856 KB Output isn't correct
5 Incorrect 491 ms 18848 KB Output isn't correct
6 Incorrect 497 ms 18752 KB Output isn't correct
7 Incorrect 509 ms 18484 KB Output isn't correct
8 Incorrect 487 ms 18824 KB Output isn't correct
9 Incorrect 667 ms 23932 KB Output isn't correct
10 Incorrect 698 ms 25524 KB Output isn't correct
11 Incorrect 707 ms 25856 KB Output isn't correct
12 Incorrect 760 ms 26212 KB Output isn't correct
13 Incorrect 835 ms 27116 KB Output isn't correct
14 Incorrect 965 ms 28648 KB Unexpected end of file - int32 expected
15 Incorrect 958 ms 28636 KB Output isn't correct
16 Execution timed out 1069 ms 29932 KB Time limit exceeded
17 Execution timed out 1052 ms 30972 KB Time limit exceeded
18 Execution timed out 1084 ms 29568 KB Time limit exceeded
19 Execution timed out 1091 ms 30356 KB Time limit exceeded
20 Execution timed out 1068 ms 30780 KB Time limit exceeded