백준 13458번: 시험 감독
2022. 6. 21. 20:11ㆍAlgorithm/백준
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class 시험감독 {
static int N; // 시험장 수
static int[] arr; // 응시자 수
static int B, C; // 총감독관이 감독할 수 있는 응시자 수 ,부감독관 감독 응시자 수
static long cnt; // 총감독관 수, 부감독관 수
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
arr = new int[N];
String str = br.readLine();
StringTokenizer st = new StringTokenizer(str);
for (int i = 0; i < arr.length; i++){
arr[i] = Integer.parseInt(st.nextToken());
}
String str2 = br.readLine();
StringTokenizer st1 = new StringTokenizer(str2);
B = Integer.parseInt(st1.nextToken());
C = Integer.parseInt(st1.nextToken());
int n = 0; // 부감독관 수를 구할 변수
for (int i = 0; i < N; i++){
if(arr[i]<=B) {
cnt++;
continue;
}else {
cnt++; // 총감독관 하나 플러스
n = arr[i]-B;
if(n%C == 0) cnt+=n/C;
else cnt+=n/C+1;
}
}
System.out.println(cnt);
}
}
728x90
'Algorithm > 백준' 카테고리의 다른 글
백준 4673번: 셀프 넘버 (0) | 2022.06.23 |
---|---|
백준 2309번: 일곱 난쟁이 (0) | 2022.03.25 |
백준 17608번: 막대기 (0) | 2022.03.20 |
백준 2810번: 컵홀더 (0) | 2022.03.19 |
백준 11726번: 2xn 타일링 (0) | 2021.09.15 |