풀이방법
먼저 총감독관을 뺀다음
나머지를 감독관수만큼 나누고 나머지가 있으면 1개를 더해주면 된다.
코드
package pro;
import java.io.*;
import java.util.*;
public class 시험감독 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
long count = 0;
StringTokenizer st= new StringTokenizer(br.readLine());
int []map = new int[N];
for(int i=0;i<N;i++) {
map[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine());
int O = Integer.parseInt(st.nextToken());
int P = Integer.parseInt(st.nextToken());
for(int i = 0; i<N; i++) {
map[i] -= O;
count++;
//부감독관으로 나머지 채우기
if(map[i] > 0) {
count += map[i]/P;
if(map[i]%P != 0) {
count++;
}
}
}
System.out.println(count);
}
}
'알고리즘' 카테고리의 다른 글
백준 - 감시(java) (0) | 2023.03.30 |
---|---|
백준 - 톱니바퀴 (0) | 2023.03.27 |
백준 - 테트로미노(14500번) (0) | 2023.03.17 |
백준 - 주사위굴리기 (0) | 2023.03.16 |
프로그래머스 - 마법의 엘리베이터 (0) | 2023.02.19 |