Farmer Jon has recently bought n tree seedlings that he /problems/plantingtrees/file/statement/en wants to plant in his yard. It takes 1 day for Jon to plant a 0001.JPG seedling!, and for each tree...


Solve in C , Asap please.


Farmer Jon has recently bought n tree seedlings that he<br>/problems/plantingtrees/file/statement/en<br>wants to plant in his yard. It takes 1 day for Jon to plant a<br>0001.JPG<br>seedling!, and for each tree Jon knows exactly in how<br>many days after planting it grows to fullmaturity. Jon would also like to throw a party for his farmer<br>friends, but in order to impress them he would like to organize the party only after all the trees have<br>grown. More precisely, the party can be organized at earliest on the next day after the last tree has<br>grown up.<br>Help Jon to find out when is the earliest day when the party can take place. Jon can choose the order of<br>planting the trees as he likes, so he wants to plant the trees in such a way that the party will be as soon<br>as possible.<br>Input<br>The input consists of two lines. The first line contains a single integer N (1 <N< 100 000) denoting<br>the number of seedlings. Then a line with N integers t; follows (1 < t; < 1000 000), where t; denotes<br>the number of days it takes for the ith tree to grow.<br>

Extracted text: Farmer Jon has recently bought n tree seedlings that he /problems/plantingtrees/file/statement/en wants to plant in his yard. It takes 1 day for Jon to plant a 0001.JPG seedling!, and for each tree Jon knows exactly in how many days after planting it grows to fullmaturity. Jon would also like to throw a party for his farmer friends, but in order to impress them he would like to organize the party only after all the trees have grown. More precisely, the party can be organized at earliest on the next day after the last tree has grown up. Help Jon to find out when is the earliest day when the party can take place. Jon can choose the order of planting the trees as he likes, so he wants to plant the trees in such a way that the party will be as soon as possible. Input The input consists of two lines. The first line contains a single integer N (1 <>< 100="" 000)="" denoting="" the="" number="" of="" seedlings.="" then="" a="" line="" with="" n="" integers="" t;="" follows="" (1="">< t;="">< 1000="" 000),="" where="" t;="" denotes="" the="" number="" of="" days="" it="" takes="" for="" the="" ith="" tree="" to="">
Output<br>You program should output exactly one line containing one integer, denoting the earliest day when the<br>party can be organized. The days are numbered 1, 2, 3, ... beginning from the current moment.<br>Sample Input 1<br>Sample Output 1<br>4<br>7<br>2 3 4 3<br>Sample Input 2<br>Sample Output 2<br>6<br>42<br>39 38 9 35 39 20<br>

Extracted text: Output You program should output exactly one line containing one integer, denoting the earliest day when the party can be organized. The days are numbered 1, 2, 3, ... beginning from the current moment. Sample Input 1 Sample Output 1 4 7 2 3 4 3 Sample Input 2 Sample Output 2 6 42 39 38 9 35 39 20

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here