Chef and Stocks CodeChef Solution
Table of Contents
We Are Discuss About CODECHEF SOLUTION
Chef and Stocks CodeChef Solution
Problem
Chef has started learning about the stock market and has already selected a favourite stock.
He traded the stock for � consecutive days. Let �� denotes the profit earned by Chef on the ��ℎ day.
Note that ��<0 indicates that Chef had a loss on the ��ℎ day.
Chef wants to find the maximum amount of of profit he would have earned, if he skipped trading for exactly one day.
Input Format
- The first line of input will contain a single integer �, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains � — the number of days.
- The next line denotes � space-separated integers, denoting the profit earned by Chef on the ��ℎ day.
Output Format
For each test case, output on a new line, the maximum amount of of profit he would have earned, if he skipped trading for exactly one day.
Constraints
- 1≤�≤1000
- 1≤�≤105
- −100≤��≤100
- The sum of � over all test cases won’t exceed 106.
Sample 1:
4 3 1 -2 3 4 4 1 5 1 4 10 -10 -10 10 5 -5 -4 -3 -2 -1
4 10 10 -10
Explanation:
Test case 1: To make maximum profit, Chef would have skipped day 2. The total profit for rest of the days is 1+3=4.
Test case 2: To make maximum profit, Chef would have skipped day 4. The total profit for rest of the days is 1+4+5=10.
Test case 3: To make maximum profit, Chef would have skipped day 3. The total profit for rest of the days is 10−10+10=10.
Test case 4: To make maximum profit, Chef would have skipped day 1. The total profit for rest of the days is −4−3−2−1=−10.
6 digit code appear after 69 seconds.
Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer Then Follow US HERE and Join Telegram.
If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE