Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You live in a strange country: every city is located on a straight line, with city i located at position i . To improve the
You live in a strange country: every city is located on a straight line, with city
located at position To improve the governance of your country, you decided to rank your cities:
more highranked cities can help to govern less highranking cities. After you assign a unique rank
to every city, each city i governs:
itself,
every city such that rankrankrankirank and there city with rank higher than rank
between i and
other words, governs all cities the left and the right until reaches a city with
a higher rank. For example, assume that have cities, and you decided assign ranks
rank Then:
City governs all the cities.
City governs cities : doesn't govern city since rankrank;
City governs only itself: cities and have a higher rank; city doesn't govern city since
they are separated city and rankrank
Similarly, city only governs itself.
Every city i has a value called importance various economic and social factors When
city i governs city the governance city increases importance For example, assume that
the above example importance Then:
City governed only itself, its governance importance
City governed cities its governance importance importance
importance ;
City governed cities its governance importance importance ;
City governed cities its governance importance importance
importance
Your goal choose the ranks the cities that the total governance maximized. the
above example, the total governance which optimal.
Please implement the following function:
vector Governance vector& importance
The function should return the maximum possible total governance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started