1956 penalty Calculation

Source: Internet
Author: User
Description

On the scoring board of the programming competition, there is a column called "penalty time". How is this strange number calculated?

You may know that there is such a comment on the "view score details" page of the Scoreboard:

Note: (x/y) -- X indicates the number of times the question was submitted, and y indicates the time when the question was first passed, in minutes.
The calculated penalty for passing questions is (X-1) * 20 + Y. If the question fails, no penalty is calculated.

Specifically, X indicates the number of times that the question was submitted before the question was submitted correctly for the first time (including the correct one), for example, in a computer, the submission record of Doudou students is as follows (the competition starts ):

· B accepted (AC)

· A wrong answer (WA)

· A wrong answer (WA) 14:59

· A wrong answer (WA)

· A accepted (AC)

· C wrong answer (WA)

· C wrong answer (WA)

· C accepted (AC)

· D accepted (AC)

· A presentation error (PE) :32

· A accepted (AC) :33

· E time limit exceeded (TLE)

For question a, x = 4 (when the question X is calculated, the submitted records after the question AC and other questions are ignored), Y = 35 (minutes ), the penalty is: (4-1) * 20 + 35 = 95;

For question E, the penalty is zero, because the question has never passed (accepted ).

Now, I want to tell you that all the submission records of beans on a computer can help you calculate the penalty?

Input

The first act is an integer m, indicating that M groups of data exist (M <10 ).

For each group of data, the first behavior is an integer N, indicating a total of N submitted records (n <20 ).

The following n rows have two integers P, T, and a string S, indicates that the P question is submitted once at the T minute after the start of the competition (1 <= P <= 5, 0 <= T <= 150), and the result is S, S is one of the seven cases ):

· Accepted (AC)

· Presentation error (PE)

· Compilation error (CE)

· Wrong answer (WA)

· Runtime error (re)

· Time limit exceeded (TLE)

· Memory limit exceeded (MLE)

For details, see the example. N records are arranged in chronological order.

Output

Output a row of data in each group, that is, the total penalty time (the sum of the penalty times for each question ).

Sample Input
2
2
1 10 WA
1 15 AC
4
1 10 WA
2 15 AC
2 17 PE
2 17 AC
Sample output
35
15
 
    

Simulation questions

# Include <stdio. h> # include <string. h> int main () {int number, T, TT; int N, I; int No, time; char upset [6]; char a [6] [6]; // question status int B [6]; // question No. Int flag [6]; // usage int count [6]; // count int temp [6]; int sum; scanf ("% d", & number); For (t = 1; t <= number; t ++) {sum = 0; for (I = 0; I <6; I ++) {B [I] = 0; count [I] = 0; flag [I] = 0; temp [I] = 0 ;} scanf ("% d", & N); For (TT = 1; TT <= N; TT ++) {scanf ("% d % s ", & No, & time, & upset); strcpy (A [No], upset); B [No] = 1; if (a [No] [0] = 'A') {If (flag [No]! = 1) {flag [No] = 1; temp [No] = Time ;}} else {If (flag [No]! = 1) Count [No] ++ ;}}for (I = 0; I <6; I ++) {If (B [I] = 1) {If (flag [I] = 1) {sum + = (count [I]) * 20 + temp [I] ;}} printf ("% d \ n", sum);} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.