# 유형 : 시뮬레이션
# 난이도 : 브론즈 2
# 정답을 long 타입으로 하지 않으면 틀린다는 점만 생각하면 바로 풀 수 있던 문제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package bj;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class p13458 {
static int N,B,C;
static int A[];
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
A = new int[N];
StringTokenizer 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());
long result = 0;
for(int index=0; index < N; index++) {
int num = A[index];
if(num - B <= 0) {
result++;
continue;
}else {
num -= B;
result++;
if(num % C == 0)
result += num/C;
else {
result += num/C;
result += 1;
}
}
// System.out.println(result);
}
System.out.println(result);
}
}
|
cs |
'백준' 카테고리의 다른 글
#백준_17143 낚시왕 - Java 자바 (0) | 2020.03.26 |
---|---|
#백준_14890 경사로 - Java 자바 (0) | 2020.03.25 |
#백준_16235 나무 재테크 - Java 자바 (0) | 2020.03.24 |
#백준_17136 색종이 붙이기 - Java 자바 (0) | 2020.03.23 |
#백준_17135 캐슬 디펜스 - Java 자바 (0) | 2020.03.21 |