all dishes are ready in various cafés and consequently Petya needs to get his orders from n better places. To accelerate this interaction, he needs to arrange messenger conveyance at certain eateries. Subsequently, for each dish, there are two choices for Petya how he can get it:    the dish will be conveyed by a dispatch from the café I, for this situation the messenger will show up in man-made intelligence

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.

all dishes are ready in various cafés and consequently Petya needs to get his orders from n better places. To accelerate this interaction, he needs to arrange messenger conveyance at certain eateries. Subsequently, for each dish, there are two choices for Petya how he can get it: 

 

the dish will be conveyed by a dispatch from the café I, for this situation the messenger will show up in man-made intelligence minutes, 

 

Petya goes to the eatery I all alone and gets the dish, he will spend bi minutes on this. 

 

Every café has its own dispatches and they begin conveying the request right now Petya goes out. As such, all dispatches work in equal. Petya should visit all cafés in which he has not picked conveyance, he does this reliably. 

 

For instance, assuming Petya needs to arrange n=4 dishes and a=[3,7,4,5], and b=[2,1,2,4], then, at that point, he can arrange conveyance from the first and the fourth eatery, and go to the second and third all alone. Then, at that point, the dispatch of the first eatery will acquire the request quite a while, the messenger of the fourth café will get the request 5 minutes, and Petya will get the leftover dishes in 1+2=3 minutes. Subsequently, in a short time every one of the dishes will be at Petya's home. 

 

Figure out the base time after which every one of the dishes can be at Petya's home. 

 

Input 

 

The primary line contains one certain integer t (1≤t≤2⋅105) — the number of experiments. Then, at that point, t experiments follow. 

 

Each experiment starts with a line containing one integer n (1≤n≤2⋅105) — the number of dishes that Petya needs to arrange. 

 

The second line of each experiment contains n integers a1… an (1≤ai≤109) — the hour of messenger conveyance of the dish with the number I. 

 

The third line of each experiment contains n integers b1… bn (1≤bi≤109) — the time during which Petya will get the dish with the number I. 

 

The amount of n over all experiments doesn't surpass 2⋅105. 

 

Output 

 

For each experiment output one integer — the base time after which everything dishes can be at Petya's home.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY