

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 300 点
問題文
高橋君は AtCoder のコンテストに参加しています。
このコンテストでは、 N 問の問題が出題されます。
高橋君はコンテスト中に M 回の提出を行いました。
i 回目の提出は p_i 番目の問題への提出であり、結果は S_i (AC
または WA
) でした。
高橋君の正答数は、AC
を 1 回以上出した問題の数です。
高橋君のペナルティ数は、高橋君が AC
を 1 回以上出した各問題において、初めて AC
を出すまでに出した WA
の数の総和です。
高橋君の正答数とペナルティ数を答えてください。
制約
- N , M , p_i は整数
- 1 ≤ N ≤ 10^5
- 0 ≤ M ≤ 10^5
- 1 \leq p_i \leq N
- S_i は
AC
かWA
のいずれか
入力
入力は以下の形式で標準入力から与えられる。
N M p_1 S_1 : p_M S_M
出力
高橋君の正答数とペナルティ数を出力せよ。
入力例 1
2 5 1 WA 1 AC 2 WA 2 AC 2 WA
出力例 1
2 2
高橋君が 1 番目の問題に初めて AC
を出したのは 2 回目の提出であり、これまでに 1 番目の問題で 1 回 WA
を出しています。
高橋君が 2 番目の問題に初めて AC
を出したのは 4 回目の提出であり、これまでに 2 番目の問題で 1 回 WA
を出しています。
以上より、高橋君の正答数は 2 であり、ペナルティ数も 2 です。
入力例 2
100000 3 7777 AC 7777 AC 7777 AC
出力例 2
1 0
同じ問題で何度 AC
を出しても無意味であることに注意してください。
入力例 3
6 0
出力例 3
0 0
Score : 300 points
Problem Statement
Takahashi participated in a contest on AtCoder.
The contest had N problems.
Takahashi made M submissions during the contest.
The i-th submission was made for the p_i-th problem and received the verdict S_i (AC
or WA
).
The number of Takahashi's correct answers is the number of problems on which he received an AC
once or more.
The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC
once or more: the number of WA
s received before receiving an AC
for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
Constraints
- N, M, and p_i are integers.
- 1 \leq N \leq 10^5
- 0 \leq M \leq 10^5
- 1 \leq p_i \leq N
- S_i is
AC
orWA
.
Input
Input is given from Standard Input in the following format:
N M p_1 S_1 : p_M S_M
Output
Print the number of Takahashi's correct answers and the number of Takahashi's penalties.
Sample Input 1
2 5 1 WA 1 AC 2 WA 2 AC 2 WA
Sample Output 1
2 2
In his second submission, he received an AC
on the first problem for the first time. Before this, he received one WA
on this problem.
In his fourth submission, he received an AC
on the second problem for the first time. Before this, he received one WA
on this problem.
Thus, he has two correct answers and two penalties.
Sample Input 2
100000 3 7777 AC 7777 AC 7777 AC
Sample Output 2
1 0
Note that it is pointless to get an AC
more than once on the same problem.
Sample Input 3
6 0
Sample Output 3
0 0