https://www.acmicpc.net/problem/10984
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
StringTokenizer st;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < T; i++) {
int N = Integer.parseInt(br.readLine());
int totalC = 0;
double totalG = 0d;
for (int j = 0; j < N; j++) {
st = new StringTokenizer(br.readLine());
int c = Integer.parseInt(st.nextToken());
double g = Double.parseDouble(st.nextToken());
totalC += c;
totalG += c * g;
}
sb.append(totalC).append(" ").append(String.format("%.1f", totalG / totalC)).append("\n");
}
System.out.println(sb);
}
}
'알고리즘 > 백준' 카테고리의 다른 글
백준 25625 샤틀버스 (0) | 2022.12.09 |
---|---|
백준 25640 MBTI (0) | 2022.12.09 |
백준 2476 주사위 게임 (0) | 2022.12.09 |
백준 2965 캥거루 세마리 (0) | 2022.12.09 |
백준 10886 0 = not cute / 1 = cute (0) | 2022.12.09 |