@@ -25,38 +25,44 @@ To avoid raising suspicions from ASIC or impacting the market significantly, you
2525
2626## Input
2727
28- - The first line contains ` T ` - the number of testcases
29- - For the next ` T ` pairs of lines (each representing a seperate testcase ):
30- - The first line contains an integer `N` - the number of days
31- - The second line contains `N` integers `price[1], price[2], ..., price[n]` - the stock prices for the next `N` days, seperated by space.
28+ - The first line contains ` T ` - the number of test cases
29+ - For the next ` T ` pairs of lines (each representing a separate test case ):
30+ - The first line contains an integer `N` - the number of days
31+ - The second line contains `N` integers `price[1], price[2], ..., price[n]` - the stock prices for the next `N` days, separated by space.
3232
3333## Output
3434
35- Output ` T ` lines of number, each contains a single integer representing the maximum profit you can make for each test case.
35+ Output a single line, containing ` T ` space-separated integers.
36+ Each integer will represent the maximum profit that you can make in each test case,
37+ corresponding in the order by which the test cases were provided.
3638
3739## Constraints
3840
39- - ` 2 <= N <= 3 * 10^5 `
40- - ` 1 <= price[i] <= 10^6 `
41- - The sum of ` N ` over all test cases will not exceed ` 3*10^5 `
41+ - ` 2 <= N <= 3 * 10^5 ` ,
42+ - ` 1 <= price[i] <= 10^6 ` ,
43+ - The sum of ` N ` over all test cases will not exceed ` 3*10^5 ` .
4244
4345## Example
4446
45- #### Input
47+ ### Input
4648
49+ In this example, ` T ` is ` 1 ` .
50+ The next two lines are thus part of the one and only test case in this example.
51+ Here, ` N ` is ` 9 ` , followed by a single line with 9 space-separated integers.
4752```
48531
49- 9
54+ 9
505510 5 4 7 9 12 6 2 10
5156```
5257
53- #### Output
58+ ### Output
5459
60+ Here, the solution is a single line containing the solution of the one test case we are provided.
5561```
566220
5763```
5864
59- #### Explanation
65+ ### Explanation
6066
6167To get the maximum profit, we will make these transactions:
6268- Buy a share at day ` 2 ` at price ` 5 `
@@ -66,4 +72,4 @@ To get the maximum profit, we will make these transactions:
6672- Buy a share at day ` 8 ` at price ` 2 `
6773- Sell a share at day ` 9 ` at price ` 10 `
6874
69- The total profit is ` 0 - 5 - 4 + 9 + 12 - 2 + 10 = 20 `
75+ The total profit is ` 0 - 5 - 4 + 9 + 12 - 2 + 10 = 20 ` .
0 commit comments