Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please give me a code in C . In the Warzone game, a mission period will continue for n days. During this time, the player
Please give me a code in C In the Warzone game, a mission period will continue for n days. During this time, the
player needs to complete missions in m different areas. The areas are numbered from
to m
Each day, the player can complete a mission for one of the m areas. However, some
days might not have any missions available for completion. The player is not allowed to
complete more than one mission in a single day.
For each day, information is given about which areas mission can be completed on that
day. On days without available missions, the player can either prepare for missions it
takes the whole day or rest.
For each area, the player knows the number of preparation days required to complete a
mission in that area. The player can switch between preparing for different areas and
does not need to prepare for a given area continuously. The player can mix the order of
preparation days as needed.
Your task is to determine the minimum number of days required for the player to
complete all missions, or determine if it is impossible to complete them. Each mission
should be completed exactly once.
The required time complexity is less than Onxm and mention your proposed solution
time complexity in the code.
Input Format:
The first line contains two integers n and m the number of days in the mission period
and the number of areas respectively.
The second line contains n integers d
d
dn for all di m where di
is the
number of the area for which a mission can be completed on day i If di equals no
mission can be completed on that day.
The third line contains m positive integers a
a
am for all ai
where ai
is
the number of days needed to prepare before completing a mission in area i
Output Format:
Print one integer the minimum number of days required for the player to complete all
missions. If it is impossible, print
Constraints:
n m
di m
ai
Example :
Output:
Example :
Output:
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