segment of place where there is length n there are k climate control systems: the I-th climate control system is set in cell artificial intelligence (1≤ai≤n). At least two climate control systems can't be put in a similar cell (for example all man-made intelligence are particular).    Each climate control

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Correct answer will upvoted else downvoted.

 

segment of place where there is length n there are k climate control systems: the I-th climate control system is set in cell artificial intelligence (1≤ai≤n). At least two climate control systems can't be put in a similar cell (for example all man-made intelligence are particular). 

 

Each climate control system is characterized by one boundary: temperature. The I-th climate control system is set to the temperature ti. 

 

Illustration of portion of length n=6, where k=2, a=[2,5] and t=[14,16]. 

 

For every cell I (1≤i≤n) discover it's temperature, that can be determined by the equation 

 

min1≤j≤k(tj+|aj−i|), 

 

where |aj−i| means outright worth of the distinction aj−i. 

 

As such, the temperature in cell I is equivalent to the base among the temperatures of forced air systems, expanded by the separation from it to the cell I. 

 

How about we take a gander at a model. Consider that n=6,k=2, the main forced air system is put in cell a1=2 and is set to the temperature t1=14 and the second forced air system is put in cell a2=5 and is set to the temperature t2=16. 

Input :The primary line contains one integer q (1≤q≤104) — the number of experiments in the input. Then, at that point, experiments follow. Before each experiment, there is an unfilled line. 

Each experiment contains three lines. The primary line contains two integers n (1≤n≤3⋅105) and k (1≤k≤n) — the length of the portion of land and the number of forced air systems individually. The subsequent line contains k integers a1,a2,… ,ak (1≤ai≤n) — places of climate control systems on the piece of land. The third line contains k integers t1,t2,… ,tk (1≤ti≤109) — temperatures of forced air systems. It is ensured that the amount of n over all experiments doesn't surpass 3⋅105. 

Output :For each experiment output n integers isolated by space: temperatures of air in cells.

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education