
문제
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV13zo1KAAACFAYh
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
풀이
단순구현 문제라 어려운 부분이 없다.
배열에 담아서 MAX를 찾은 게 전부다
소스 코드
#include<iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(int argc, char** argv)
{
int test_case;
int T;
cin>>T;
for(test_case = 1; test_case <= T; ++test_case)
{
int N;
cin >> N;
int arr[1001];
int max = 0;
memset(arr, 0, sizeof(arr));
for (int i = 0; i < 1000; i++) {
int num;
cin >> num;
arr[num] += 1;
if (arr[num] > arr[max]) {
max = num;
}
if (arr[num] == arr[max]) {
if (max > num)
;
else
max = num;
}
}
cout << "#" << test_case << " " << max << '\n'; }
return 0;
}'Programming Practice > SWEA' 카테고리의 다른 글
| [SWEA] 1249. 보급로 - D4 (0) | 2022.05.10 |
|---|---|
| [SWEA] 1954. 달팽이 - D2 (0) | 2022.05.10 |
| [SWEA] 1244. 최대 상금 - D3 (0) | 2022.05.03 |
| [SWEA] 1206. View - D3 (0) | 2022.05.02 |
| [SWEA] 1859. 백만장자 프로젝트 - D2 (0) | 2022.05.02 |