Electrical Outlets


Time Limit: 2 Seconds      Memory Limit: 65536 KB

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 electricity 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 many 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 electricity, 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 vill 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, O1O2...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

3
3 2 3 4
10 4 4 4 4 4 4 4 4 4 4
4 10 10 10 10

Sample Output

7
31
37

题意:墙壁上只有一个电源插座,但是有很多插件板,每个插件板上有若干插座。求每组插件板最多能插入电器的数量

 #include <iostream>
#include <cstdio>
using namespace std;
int main(){
int n, k;
int sum, temp;
cin >> n;
while(n--){
sum = ;
cin >> k;
for(int i = ; i < k; i++){
cin >> temp;
sum += temp;
}
cout << sum + - k << endl;//所有插件板上的插座总数+墙壁上的一个电源插座-每个插件板需要占据一个插座
}
return ;
}

zoj 2807 Electrical Outlets的更多相关文章

  1. POJ 2636:Electrical Outlets

    Electrical Outlets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9597   Accepted: 718 ...

  2. HDOJ(HDU) 2304 Electrical Outlets(求和、、)

    Problem Description Roy has just moved into a new apartment. Well, actually the apartment itself is ...

  3. POJ解题经验交流

    感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理.   题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...

  4. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  5. What is Cross Linux From Scratch?

    /**************************************************************************** * What is Cross Linux ...

  6. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  7. OJ题解记录计划

    容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2 ...

  8. 算法之路 level 01 problem set

    2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...

  9. ESXi服务器遇到 IPMI_SI_DRV 的解决, 感谢原作者 以及今天 解决问题.

    ESXI 服务器断电之后一直 LOADING MODULE IPMI_SI_DRV 的解决办法 今日家中忽然断电,之后 ESXi 服务器就一直疯狂转,连接显示器,发现原来一直没有启动.停留在ESXi  ...

随机推荐

  1. 523 Continuous Subarray Sum 非负数组中找到和为K的倍数的连续子数组

    非负数组中找到和为K的倍数的连续子数组 详见:https://leetcode.com/problems/continuous-subarray-sum/description/ Java实现: 方法 ...

  2. Spark MLlib编程API入门系列之特征选择之R模型公式(RFormula)

    不多说,直接上干货! 特征选择里,常见的有:VectorSlicer(向量选择) RFormula(R模型公式) ChiSqSelector(卡方特征选择). RFormula用于将数据中的字段通过R ...

  3. javajsp,Servlet:Property 'Id' not found

    avax.el.PropertyNotFoundException: Property 'Id' not found on type  org.androidpn.server.model.CarSo ...

  4. CMSIS的简介

    Cortex微控制器软件接口标准(Cortex Microcontroller Software Interface Standard)是ARM和一些编译器厂家以及半导体厂家共同遵循的一套标准,是由A ...

  5. win10忘记wifi记录

    1.点击桌面右下角无线图标 2.点击网络设置 3.点击管理WIFI设置 4.点击要管理的账户,忘记或者共享该wifi.

  6. MongoDB最简单的入门教程之三 使用Java代码往MongoDB里插入数据

    前两篇教程我们介绍了如何搭建MongoDB的本地环境: MongoDB最简单的入门教程之一 环境搭建 以及如何用nodejs读取MongoDB里的记录: MongoDB最简单的入门教程之二 使用nod ...

  7. 原创:Nginx反向代理实战部署

    均衡负载服务器 10.0.0.9 [root@web03 conf]# vim nginx.conf worker_processes  1; events { worker_connections  ...

  8. MMRecovery下载和恢复方法教程

    如何能下载到最新版本的恢复软件MMRecovery?下载后我们如何能够快速的使用起来呢?好的,我们接下来就开始这些内容. 一.下载最新版本的恢复软件MMRecovery 1.官方网站下载,如下图在浏览 ...

  9. Postman 安装及使用入门教程 | 前后台 写接口的 徐工给的

    https://www.cnblogs.com/mafly/p/postman.html

  10. Asp.Net Core 入门(三) —— 自定义中间件

    上一篇我们讲了Startup文件,其中着重介绍了中间件,现在我们就来自定义我们自己的中间件吧. 中间件通常封装在一个类中,并使用扩展方法进行暴露.它需要拥有一个类型为RequestDelegate的成 ...