• 문제 링크
16237번: 이삿짐센터
첫째 줄에 A, B, C, D, E가 주어진다. (0 ≤ A, B, C, D, E ≤ 1,000)
www.acmicpc.net
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int a = read(), b = read(), c = read(), d = read(), e = read(), cnt = c + d + e;
a -= d;
if (b < c) a -= (c - b) * 2;
else if ((b -= c) > 0) {
cnt += b / 2;
a -= b / 2;
if (b % 2 == 1) {
cnt++;
a -= 3;
}
}
if (a > 0) cnt += (a + 4) / 5;
bw.write(String.valueOf(cnt));
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 6092 Strange Towers of Hanoi - Dynamic Programming / Java (0) | 2024.02.16 |
---|---|
[백준] 25972 도미노 무너트리기 - Greedy / Java (0) | 2024.02.15 |
[백준] 16200 해커톤 - Greedy / Java (0) | 2024.02.13 |
[백준] 14720 우유 축제 - Greedy / Java (0) | 2024.02.12 |
[백준] 27940 가지 산사태 - Greedy / Java (0) | 2024.02.11 |
댓글