ContestWinner
SRM 546 · 2011-11-22 · by misof
Problem Statement
Exactly one million contestants, numbered 1 through 1,000,000, took part in a programming contest. The rules of the contest are simple: the winner is the contestant who solves the largest number of tasks. If there are more contestants tied for most tasks solved, the winner is the one who was the first to have all of their tasks solved.
During the contest the judges were keeping a log of all accepted solutions.
You are given this log as a
For example, if events = {4, 7, 4, 1}, this is what happened during the contest:
- Contestant 4 solved her first task.
- Contestant 7 solved his first task.
- Contestant 4 solved her second task.
- Contestant 1 solved his first task.
Compute and return the number of the contestant who won the contest.
Constraints
- events will contain between 1 and 50 elements, inclusive.
- Each element of events will be between 1 and 1,000,000, inclusive.
{4,7,4,1}
Returns: 4
Example from the problem statement.
{10,20,30,40,50}
Returns: 10
{123,123,456,456,456,123}
Returns: 456
{1,2,2,3,3,3,4,4,4,4}
Returns: 4
{47}
Returns: 47
Submissions are judged against all 85 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ContestWinner with a public method int getWinner(vector<int> events) · 85 test cases · 2 s / 256 MB per case