페이지

2592번: 대표값

https://www.acmicpc.net/problem/2592


$O(1)$


#include<cstdio>
#include<algorithm>
int s, a[1000];
int main() {
    for (int i = 0, x; i < 10; i++) scanf("%d", &x), a[x]++, s += x;
    printf("%d\n%d", s / 10, std::max_element(a, a + 1000) - a);
    return 0;
}

댓글 없음 :

댓글 쓰기