-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathThat Is My Score!
51 lines (42 loc) · 2.47 KB
/
That Is My Score!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
). The first eight problems (i.e. problems 1,2,…,8) are scorable, while the last three problems (9, 10 and 11) are non-scorable ― this means that any submissions you make on any of these problems do not affect your total score.
Your total score is the sum of your best scores for all scorable problems. That is, for each scorable problem, you look at the scores of all submissions you made on that problem and take the maximum of these scores (or 0 if you didn't make any submissions on that problem); the total score is the sum of the maximum scores you took.
You know the results of all submissions you made. Calculate your total score.
Input
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the number of submissions you made.
N lines follow. For each i (1≤i≤N), the i-th of these lines contains two space-separated integers pi and si, denoting that your i-th submission was on problem pi and it received a score si.
Output
For each test case, print a single line containing one integer ― your total score.
Constraints
1≤T≤10
1≤N≤1,000
1≤pi≤11 for each valid i
0≤si≤100 for each valid i
Subtasks
Subtask #1 (15 points): all submissions are on the same problem, i.e. p1=p2=…=pN
Subtask #2 (15 points): there is at most one submission made on each problem, i.e. pi≠pj for each valid i,j (i≠j)
Subtask #3 (70 points): original constraints
Example Input
2
5
2 45
9 100
8 0
2 15
8 90
1
11 1
Example Output
135
0
Explanation
Example case 1: The scorable problems with at least one submission are problems 2 and 8. For problem 2, there are two submissions and the maximum score among them is 45. For problem 8, there are also two submissions and the maximum score is 90. Hence, the total score is 45+90=135.
Example case 2: No scorable problem is attempted, so the total score is 0.
Author: vijju123_adm
Editorial: https://discuss.codechef.com/problems/WATSCORE
Tags: array, cakewalk, dec19, maximum, melfice, sum, vijju123_adm
Date Added: 27-11-2019
Time Limit: 1 secs
Source Limit: 50000 Bytes
Languages: C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS
Submit