• 문제 링크
21146번: Rating Problems
Output two space-separated floating point numbers on a single line, which are the minimum and maximum overall rating the problem could achieve after the remaining judges rate the problem, minimum first. These values must be accurate to an absolute or relat
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 n = read(), k = read();
float sum = 0;
for (int i = 0; i < k; i++) sum += read();
bw.write((sum + -3 * (n - k)) / n + " " + (sum + 3 * (n - k)) / n);
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
boolean flag = n == 13;
if (flag) n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return flag ? ~n + 1 : n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 11597 Excellence - Greedy / Java (0) | 2024.04.15 |
---|---|
[백준] 27851 Watching Mooloo - Greedy / Java (0) | 2024.04.14 |
[백준] 15001 Frog Leaps - Greedy / Java (0) | 2024.04.12 |
[백준] 27106 Making Change - Greedy / Java (0) | 2024.04.11 |
[백준] 3578 Holes - Greedy / Java (0) | 2024.04.10 |
댓글