티스토리 뷰

출처 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV13zo1KAAACFAYh


#include <iostream>

#include <algorithm>

#include <memory.h>

using namespace std;


int result, a, z;

int arr[101];


int main()

{

int T; int t;

cin >> T;

while (T--)

{

cin >> t; result = 0; memset(arr, 0, sizeof(arr)); int n = 1000; z = -1;

while (n--)

{

cin >> a;

arr[a]++;

if (result <= arr[a]) {

if (result == arr[a]) z = max(z, a);

else z = a;

result = arr[a]; 

}

}


cout << "#" << t << " " << z << endl;

}


return 0;

}


'알고리즘 > SWEA' 카테고리의 다른 글

[SWEA 1210] Ladder1  (0) 2018.08.06
[SWEA 1209] Sum  (0) 2018.08.06
[SWEA 1208] Flatten  (0) 2018.08.06
[SWEA 1206] View  (0) 2018.08.05
[SWEA 4672] 수진이의 팰린드롬  (0) 2018.07.29
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함