Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Xavier needs to defuse N bombs from 1 to N . Every ith bomb is gonna explode in Y _ { 1 } seconds. He

Xavier needs to defuse N bombs from 1 to N.
Every ith bomb is gonna explode in Y_{1} seconds. He takes X_{i} seconds to defuse th bomb and he must defuse this bomb before or at this time to survive.He can only defuse one bomb at a time.
Xavier having this information beforehand has reached out to you for your help. Rescue Xavier to let him know if it is safe for him to defuse all the bombs. If he can, return minimum time by which all the bombs can be defused; if he cannot, return -1.
Example:
N: 5
bombinfo:
[[2,4]
[1,9]
[1,8]
[4,9]
[3,12]]
Give c++ code for these constraints
[input] integer n
1<= N <=2*10^5
[input] array.array.integer bombinfo
bombinfo is a given 2D array of N Rows and 2 columns
X_i represents time taken by Xavier to defuse i
th bomb Y_i represents time by which ith bomb will explode
1<= X_{i}, Y_i <=10^9(1<= i<=N)
[output] integer64

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

7. Identify four antecedents that influence intercultural contact.

Answered: 1 week ago

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago