[SWEA] 보충학습과 평균

문제 보러가기

제한사항

점수는 모두 0이상 100이하인 5의 배수이다. 즉 평균은 항상 정수이다.

첫번째 생각

40점 이하만 체크해서 40점으로 생각해서 계산하면 된다.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int tc=1; tc<=T; tc++) {
			int sum = 0;
			for(int i=0; i<5; i++) {
				int tmp = sc.nextInt();
				sum += tmp < 40 ? 40 : tmp;
			}
			System.out.println("#"+tc+" "+sum/5);
		}
	}
}