A charity marathon rewards volunteers with bonus hours toward next year's registration priority. Every volunteer has a unique bib number, a name, and the number of hours they logged at the event. A volunteer earns bonus hours equal to their logged hours only when both of the following hold: their bib number is odd, and the first character of their name is not an uppercase Q (the check is case-sensitive, so a lowercase q does not disqualify a volunteer). Every other volunteer earns 0 bonus hours. Compute the bonus hours for every volunteer and list the results in increasing order of bib number.
Line 1: an integer n — the number of volunteers.
Each of the next n lines contains a bib number, a name, and logged hours, space-separated: bib_i name_i hours_i.
Print n lines, one per volunteer, sorted by ascending bib number. Each line contains two space-separated integers: the bib number and the bonus hours earned.
1 <= n <= 10001 <= bib_i <= 10000, and all bib numbers are distinctname_i consists of 1 to 15 uppercase and lowercase English letters (no spaces)1 <= hours_i <= 100000Example 1
Input
3 3 Alice 40 4 Bob 30 7 Quinn 50
Expected
3 40 4 0 7 0
Explanation
Bib 3 is odd and 'Alice' doesn't start with 'Q', so bonus = 40. Bib 4 is even, so bonus = 0 regardless of name. Bib 7 is odd but 'Quinn' starts with uppercase 'Q', so bonus = 0. Already sorted by bib: 3 40, 4 0, 7 0.
Example 2
Input
2 2 Maria 20 5 quinn 15
Expected
2 0 5 15
Explanation
Bib 2 is even, so bonus = 0. Bib 5 is odd, and 'quinn' starts with a lowercase 'q' -- since the check is case-sensitive against uppercase 'Q', a lowercase 'q' does not disqualify the volunteer, so bonus = 15. Sorted by bib: 2 0, 5 15.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →