페이지

2822번: 점수 계산

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


$O(1)$


#include<cstdio>
int s, a[151], b[9];
int main() {
    for (int i = 1, x; ~scanf("%d", &x); i++) a[x] = i;
    for (int i = 150, j = 0; j<5; i--) if (a[i]) s += i, b[a[i]] = 1, j++;
    printf("%d\n", s);
    for (int i = 1; i <= 8; i++) if (b[i]) printf("%d ", i);
    return 0;
}

댓글 없음 :

댓글 쓰기