FoxAndVacation
SRM 561 · 2012-06-05 · by cgy4ever
Problem Statement
Additionally, different cities may require her to stay for a different number of days. For each i, city i only counts as visited if Ciel spends at least d[i] days in the city.
You are given the
Notes
- When solving the task, ignore travel times. (Fox Ciel always travels at night, and she can travel between any two cities very quickly.)
Constraints
- total will be between 1 and 50, inclusive.
- d will contain between 1 and 50 elements, inclusive.
- Each element of d will be between 1 and 50, inclusive.
5
{2,2,2}
Returns: 2
Fox Ciel's vacation lasts for 5 days. She needs at least 2 days to visit each of the cities, so she can visit at most 2 of them.
5
{5,6,1}
Returns: 1
She can only visit one city: either city 0, or city 2.
5
{6,6,6}
Returns: 0
This time the poor Fox Ciel cannot visit any city during her summer vacation.
6
{1,1,1,1,1}
Returns: 5
In this test case Ciel can visit all five cities. Note that at the end of her trip each city either does count as visited, or it does not -- there is no way to "visit" the same city twice.
10
{7,1,5,6,1,3,4}
Returns: 4
Submissions are judged against all 133 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FoxAndVacation with a public method int maxCities(int total, vector<int> d) · 133 test cases · 2 s / 256 MB per case