/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 266 点
問題文
高橋君は、野生の花の観察記録をつけています。今日の散歩で、N 個の花を見つけて、それぞれの写真を撮りました。
それぞれの花には、1 から 100 までの品種番号が付けられています。高橋君は図鑑を作成するために、同じ品種の花が複数見つかった場合は 1 枚だけを図鑑に載せることにしました。つまり、図鑑には各品種につき最大 1 枚の写真が載ります。
各花の品種番号が見つけた順に与えられたとき、図鑑に載せる写真の枚数(すなわち、見つけた花の品種の種類数)と、図鑑に載るすべての品種番号の合計を求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq S_i \leq 100
- 入力はすべて整数
入力
N S_1 S_2 \ldots S_N
- 1 行目には、見つけた花の個数を表す整数 N が与えられる。
- 2 行目には、各花の品種番号を表す N 個の整数 S_1, S_2, \ldots, S_N がスペース区切りで与えられる。S_i は i 番目に見つけた花の品種番号を表す。
出力
図鑑に載せる写真の枚数と、図鑑に載るすべての品種番号の合計を、スペース区切りで 1 行に出力せよ。
入力例 1
5 3 1 4 1 5
出力例 1
4 13
入力例 2
10 7 2 7 3 2 8 3 7 1 4
出力例 2
6 25
入力例 3
20 50 25 75 25 100 50 30 75 25 100 1 30 50 99 1 75 42 99 42 88
出力例 3
9 510
Score : 266 pts
Problem Statement
Takahashi is keeping observation records of wild flowers. During today's walk, he found N flowers and took a photo of each one.
Each flower is assigned a species number from 1 to 100. To create an encyclopedia, Takahashi decided that if multiple flowers of the same species are found, only one photo will be included in the encyclopedia. In other words, the encyclopedia contains at most one photo per species.
Given the species numbers of each flower in the order they were found, determine the number of photos to be included in the encyclopedia (i.e., the number of distinct species among the found flowers) and the sum of all species numbers included in the encyclopedia.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq S_i \leq 100
- All inputs are integers
Input
N S_1 S_2 \ldots S_N
- The first line contains an integer N representing the number of flowers found.
- The second line contains N integers S_1, S_2, \ldots, S_N separated by spaces, representing the species numbers of each flower. S_i represents the species number of the i-th flower found.
Output
Print the number of photos to be included in the encyclopedia and the sum of all species numbers included in the encyclopedia, separated by a space, on a single line.
Sample Input 1
5 3 1 4 1 5
Sample Output 1
4 13
Sample Input 2
10 7 2 7 3 2 8 3 7 1 4
Sample Output 2
6 25
Sample Input 3
20 50 25 75 25 100 50 30 75 25 100 1 30 50 99 1 75 42 99 42 88
Sample Output 3
9 510