답안 #306288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306288 2020-09-25T04:37:53 Z Swab Job Scheduling (CEOI12_jobs) Java 11
컴파일 오류
0 ms 0 KB
import java.util.Arrays;
import java.util.Scanner;

public class Week2Jobs {

	public static int n, d, m;
	public static int[] days;
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		n = scanner.nextInt();
		d = scanner.nextInt();
		m = scanner.nextInt();
		
		days = new int[m];
		
		Day[] days2 = new Day[m];
		
		for(int i=0; i<m; i++) {
			int a = scanner.nextInt();
			days[i] = a;
			days2[i] = new Day(i,a);
		}
		
		Arrays.sort(days);
		
		int lowerbound = 1;
		int upperbound = m;
		
		int a = lowerbound;
		int b = upperbound;
		
		while(a!=b) {
			
			int mid = (a+b)/2;
			
			if(works(mid)) {
				b=mid;
			}
			else {
				a = mid+1;
			}
			
		}
		
		System.out.println(a);
		
		int[] marked = new int[a];
		
		Arrays.sort(days2);
		
		
		
		for(int i=0; i<m; i++) {
			if(marked[i%a]==0) {
				marked[i%a] = days2[i].day;
				//System.out.println(days2[i].day+" " + days2[i].index+" ");
				continue;
			}
			if(marked[i%a]>=days2[i].day) {
				int temp = marked[i%a]+1;
				marked[i%a] = temp;
				days2[i] = new Day(days2[i].index, temp);
			}
			//System.out.println(days2[i].day+" "+days2[i].index+ " ");
			//System.out.println(marked[i%a]);
			marked[i%a] = days2[i].day;
		}
		
		int j = 0;
		for(int i=1; i<=n; i++) {
			while(j<m&&days2[j].day==i) {
				System.out.print(days2[j].index+1 + " ");
				j++;
			}
			System.out.println("0");
		}
		
		
		
	}
	
	public static boolean works(int mid) {
		
		int[] marked = new int[mid];
		
		for(int i=0; i<m; i++) {
			if(marked[i%mid]==0) {
				marked[i%mid] = days[i];
				continue;
			}
			if(marked[i%mid]>=days[i]) {
				int temp = marked[i%mid]+1;
				if(temp-days[i]>d) {
					return false;
				}
				marked[i%mid] = temp;
				continue;
			}
			marked[i%mid] = days[i];
		}
		
		return true;
		
	}
	
	public static class Day implements Comparable<Day>{
		
		int index, day;
		
		public Day(int index, int day) {
			this.index = index;
			this.day = day;
		}

		
		public int compareTo(Day o) {
			
			return day-o.day;
		}
		
		
		
	}

}

Compilation message

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