241226 시험 감독

Jongleee·2024년 12월 26일
0

TIL

목록 보기
766/859
public static void main(String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(br.readLine());
	int[] students = new int[n];
	StringTokenizer st = new StringTokenizer(br.readLine());

	for (int i = 0; i < n; i++) {
		students[i] = Integer.parseInt(st.nextToken());
	}

	st = new StringTokenizer(br.readLine());
	int mainSupervisor = Integer.parseInt(st.nextToken());
	int subSupervisor = Integer.parseInt(st.nextToken());

	System.out.println(calculateSupervisors(students, mainSupervisor, subSupervisor));
}

private static long calculateSupervisors(int[] students, int mainSupervisor, int subSupervisor) {
	long totalSupervisors = 0;

	for (int studentsInRoom : students) {
		totalSupervisors += 1;
		int remaining = studentsInRoom - mainSupervisor;
		if (remaining > 0) {
			totalSupervisors += remaining / subSupervisor;
			if (remaining % subSupervisor != 0) {
				totalSupervisors++;
			}
		}
	}
	return totalSupervisors;
}

출처:https://www.acmicpc.net/problem/13458

0개의 댓글

관련 채용 정보