프로그래밍 공부

SWEA 1204 최빈수 본문

Problem Solving/SW Expert Academy

SWEA 1204 최빈수

khj1999 2023. 11. 19. 12:37

 

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		int arr[101];
		int tc, ans, max = 0;
		fill(arr, arr + 100, 0);
		cin >> tc;
		for (int j = 0; j < 1000; j++) {
			int tmp;
			cin >> tmp;
			arr[tmp]++;
		}
		for (int j = 0; j < 100; j++) {
			if (max <= arr[j]) {
				max = arr[j];
				ans = j;
			}
		}
		cout << "#" << i + 1 << " " << ans << '\n';
	}
	return 0;
}

(단, 최빈수가 여러 개 일 때에는 가장 큰 점수를 출력하라). 이 조건만 조심하면 된다

'Problem Solving > SW Expert Academy' 카테고리의 다른 글

SWEA 1974 스도쿠 검증  (1) 2023.11.19
SWEA 1209 Sum  (1) 2023.11.19
1208 Flatten  (2) 2023.11.19
1205 View  (1) 2023.11.18
1240 단순 2진 암호코드  (0) 2023.11.18
Comments