https://www.acmicpc.net/problem/13458
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static int N, B, C;
public static long ans = 0;
public static int[] A;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
// 1. 입력받기
N = Integer.parseInt(br.readLine());
A = new int[N];
st = new StringTokenizer(br.readLine());
for(int i =0;i<N;i++) {
A[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine());
B = Integer.parseInt(st.nextToken());
C = Integer.parseInt(st.nextToken());
// 2. 감독관 수 세기
for(int i =0;i<N;i++) {
int result = A[i] - B;
if((result) <= 0) {
ans += 1;
continue;
}
if(result <= C) {
ans += 2;
}else if(result % C == 0){
ans += (result / C) + 1;
} else {
ans += (result / C) + 2;
}
}
// 3. 출력하기
System.out.println(ans);
}
}
'코딩테스트 > JAVA' 카테고리의 다른 글
[백준 JAVA] 13913번: 숨바꼭질 4 (0) | 2024.09.30 |
---|---|
[SWEA JAVA] 3282. 0/1 Knapsack (0) | 2024.09.30 |
[백준 JAVA] 13418번: 학교 탐방하기 (1) | 2024.09.24 |
[백준 JAVA] 1647번: 도시 분할 계획 (0) | 2024.09.24 |
[SWEA JAVA] 5650. [모의 SW 역량테스트] 핀볼 게임 (2) | 2024.09.22 |