1232. Electrical outlets

Source: Internet
Author: User

1232. Electrical outlets

Description

Roy has just moved into a new apartment. well, actually the apartment itself is not very new, even dating back to the days before people had Atomicity in their houses. because of this, Roy's apartment has only
One single wall outlet, so Roy can only power one of his electrical appliances at a time.
Roy likes to watch TV as he works on his computer, and to listen to his hifi system (on high volume) while He vacuums, so using just the single outlet is not an option. actually, he wants to have all his appliances connected to a powered outlet, all the time.
The answer, of course, is power strips, and Roy has some old ones that he used in his old apartment. however, that apartment had has more wall outlets, so he is not sure whether his power strips will provide him with enough outlets now.
Your task is to help Roy compute how many appliances he can provide with atomicity, given a set of power strips. note that without any power strips, Roy can power one single appliance through the wall outlet. also, remember that a power strip has to be powered
Itself to be of any use.

Input

Input will start with a single integer 1 <= n <= 20, indicating the number of test cases to follow. then follow n lines, each describing a test case. each test case starts with an integer 1 <= k <= 10, indicating
The number of power strips in the test case. then follow, on the same line, K integers separated by single spaces, O1 O2... OK, where 2 <= oi <= 10, indicating the number of outlets in each power strip.

Output

Output one line per test case, with the maximum number of appliances that can be powered.

Sample Input

33 2 3 410 4 4 4 4 4 4 4 4 4 44 10 10 10 10
Sample output

73137

// source code of submission 966251, Zhongshan University Online Judge System#include <iostream>using namespace std;int main(){    int n,m,a[10],sum;    cin >> n;    for (int i = 1; i <= n;i++)    {        cin >> m;        sum = 0;        for (int k = 0; k < m; k++)        {            cin >> a[k];            sum += a[k];        }        cout << sum - m + 1 << endl;    }    return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.