Two customer-support desks are competing for a monthly recognition award based on first-contact ticket resolutions. You are given the two desks' names and a log of ticket outcomes; each entry names the desk that handled the ticket and whether it was resolved on first contact (1) or not (0). Every entry's desk name is guaranteed to be one of the two given names.
A desk becomes the champion only if its resolved-ticket count is at least 2 greater than the other desk's resolved-ticket count. Determine and print the champion's name, or No Winner if neither desk leads by 2 or more (including when the counts are equal or differ by exactly 1).
Line 1: two distinct desk names, deskA and deskB, separated by a space (each a non-empty string of at most 20 printable non-whitespace characters).
Line 2: an integer n, the number of ticket entries.
Next n lines: each contains a desk name (equal to deskA or deskB) followed by a space and 0 or 1.
Print deskA if its resolved count is at least 2 more than deskB's, print deskB if its resolved count is at least 2 more than deskA's, otherwise print No Winner.
n <= 1000deskA != deskBdeskA or deskB exactly.Example 1
Input
Ridge Vale 4 Ridge 1 Ridge 1 Ridge 1 Vale 1
Expected
Ridge
Explanation
Ridge resolves 3 tickets and Vale resolves 1. Ridge's count (3) is at least 2 more than Vale's (1), since 3 >= 1+2, so Ridge is the champion.
Example 2
Input
Ridge Vale 3 Ridge 1 Vale 1 Vale 0
Expected
No Winner
Explanation
Ridge resolves 1 ticket and Vale resolves 1 ticket (the third entry is unresolved and not counted). The counts are equal, so neither desk leads by 2 or more, and the result is No Winner.
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 →