Submission #447988

#TimeUsernameProblemLanguageResultExecution timeMemory
447988VishnuJob Scheduling (CEOI12_jobs)Java
Compilation error
0 ms0 KiB
import java.io.IOException; import java.io.File; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner myObj = new Scanner(System.in); int n = myObj.nextInt(); int d = myObj.nextInt(); int m = myObj.nextInt(); int [][] arr = new int [m][2]; for (int index = 0; index < m; index++) { arr[index][0] = myObj.nextInt(); arr[index][1] = index + 1; } Arrays.sort(arr, new Comparator<int[]>() { @Override public int compare(int[] o1, int[] o2) { Integer pos1 = o1[0]; Integer pos2 = o2[0]; if (pos1 > pos2) return 1; else if (pos1 == pos2) return 0; else return -1; } }); // for (int index = 0; index < m; index++) { // System.out.println("Request: " + arr[index][0]); // System.out.println("Index: " + arr[index][1]); // } int a = 1; int b = m; int mid; while (a != b) { mid = (a+b)/2; if (works(mid, m, arr, d)) { b = mid; } else { a = mid + 1; } } System.out.println(a); String output = ""; int [] mach = new int [a]; int machine = 0; for (int index = 0; index < m; index++) { mach[machine] += 1; output = output + String.valueOf(arr[index][1]); machine++; output = output + " "; if (machine == a) { Arrays.sort(mach); machine = 0; output = output + "0\n"; } } int needFinish = n - (m/a); for (int index = 0; index < needFinish; index++) { output = output + "0\n"; } System.out.println(output); } public static boolean works (int mid, int m, int [][] request_arr, int allowDelay) { int [] mach = new int [mid]; int delay = 0; int machine = 0; for (int index = 0; index < m; index++) { mach[machine] += 1; delay = mach[machine] - request_arr[index][0]; if (delay > allowDelay) { return false; } machine++; if (machine == mid) { Arrays.sort(mach); machine = 0; } } return true; } } //8 2 12 //1 2 4 2 1 3 5 6 2 3 6 4

Compilation message (stderr)

jobs.java:9: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error