Gperm
SRM 696 · 2016-07-09 · by subscriber
Problem Statement
Constraints
- x will contain between 1 and 20 elements, inclusive.
- x and y will contain the same number of elements.
- Each element in x and y will be between 0 and 49, inclusive.
{0}
{1}
Returns: 1
One optimal order of painting the vertices is 49, 48, 47, ..., 3, 2, 1, 0. The first 49 times the fee is 0. After Hero paints the last vertex, the last fee is 1.
{0,1}
{1,2}
Returns: 2
One optimal order of painting these vertices is 49, 48, ..., 5, 4, 3, 0, 2, 1. The last three fees will be 0, 0, and 2.
{4,7,7}
{7,4,4}
Returns: 3
{0,0,1}
{1,2,2}
Returns: 4
Hero should first paint the 47 isolated vertices and then the remaining three vertices in any order. Regardless of the order in which Hero paints the last three vertices, the last three fees will be 0, 1, and 3.
{7,8,9}
{4,5,6}
Returns: 6
Submissions are judged against all 166 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Gperm with a public method int countfee(vector<int> x, vector<int> y) · 166 test cases · 2 s / 256 MB per case