TableSeating
SRM 249 · 2005-06-29 · by AdminBrett
Problem Statement
Notes
- Return values must be accurate to 1e-9, relative or absolute.
Constraints
- numTables will be between 1 and 12 inclusive.
- probs will contain between 1 and 12 elements inclusive.
- Each element of probs will be between 0 and 100 inclusive.
- The elements of probs will sum to 100.
4
{100}
Returns: 4.0
Since every party needs only 1 table, you will always fill the restaurant before turning someone away.
4
{0,100}
Returns: 3.3333333333333335
Now every party wants 2 tables. One third of the time, the first party will choose the middle 2 tables blocking anyone else from being seated. Two thirds of the time, the first party will choose 2 tables on the end allowing the restaurant to become full. Thus, the returned value is (1/3)*2 + (2/3)*4 = 10/3.
5
{0,0,0,0,0,50,50}
Returns: 0.0
You have 5 tables, but every party needs 6 or 7 tables.
12
{9,9,9,9,9,9,9,9,9,9,10}
Returns: 7.871087929710551
12
{50,50}
Returns: 10.481925778559631
Submissions are judged against all 71 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TableSeating with a public method double getExpected(int numTables, vector<int> probs) · 71 test cases · 2 s / 256 MB per case