zoj 2807 Electrical Outlets
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的更多相关文章
- POJ 2636:Electrical Outlets
		
Electrical Outlets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9597 Accepted: 718 ...
 - HDOJ(HDU) 2304 Electrical Outlets(求和、、)
		
Problem Description Roy has just moved into a new apartment. Well, actually the apartment itself is ...
 - POJ解题经验交流
		
感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理. 题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...
 - 杭电ACM分类
		
杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...
 - What is Cross Linux From Scratch?
		
/**************************************************************************** * What is Cross Linux ...
 - HOJ题目分类
		
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
 - OJ题解记录计划
		
容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001 A+B Problem First AC: 2 ...
 - 算法之路 level 01 problem set
		
2992.357000 1000 A+B Problem1214.840000 1002 487-32791070.603000 1004 Financial Management880.192000 ...
 - ESXi服务器遇到 IPMI_SI_DRV 的解决, 感谢原作者 以及今天 解决问题.
		
ESXI 服务器断电之后一直 LOADING MODULE IPMI_SI_DRV 的解决办法 今日家中忽然断电,之后 ESXi 服务器就一直疯狂转,连接显示器,发现原来一直没有启动.停留在ESXi ...
 
随机推荐
- SpringMVC的Controller的返回值与接收的参数
			
内容参考自博客: http://blog.csdn.net/u011001084/article/details/52846791 http://blog.csdn.net/xuxiaoyinliu/ ...
 - iOS 项目代码组织
			
参考了很多系列,发现老外们都比较喜欢 group by type,这两个还不错: http://akosma.com/2009/07/28/code-organization-in-xcode-pro ...
 - Jenkins视图使用--添加删除视图
			
job建立的特别多的时候,我们可能不太容易找到自己的某个job,这时,我们就可以在Jenkins中建立视图.job的视图类似于我们电脑上的文件夹.可以通过一些过滤规则,将已经建好的job过滤到视图中, ...
 - 前端打印console
			
很多时候,我们都想知道,是否已经选中或得到数据时,我们可以利用console 打印出来.console有几种方式使用.具体有: console.log($scope.getParkId); conso ...
 - dangerouslySetHTML 和 style 属性
			
这一节我们来补充两个之前没有提到的属性,但是在 React.js 组件开发中也非常常用,但是它们也很简单. dangerouslySetHTML 出于安全考虑的原因(XSS 攻击),在 React.j ...
 - 进程间通信的两种实现方式(IPC)
			
进程间通信的两种实现方式(IPC) IPC: iter processing communicate 进程间通信:IPC(iter process communicate)linux free-m 可 ...
 - obj.style 和currentstyle 等区别
			
版权声明:本文为博主原创文章,未经博主允许不得转载. 获取样式 obj.style 和currentstyle 等区别 obj.style只能获得内嵌样式(inline Style)就是写 ...
 - vue路由导航守卫及前置后置钩子函数参数详解
			
首先构建一个测试demo如下图: 接着来探讨路由配置界面 import Vue from 'vue' import Router from 'vue-router' // import HelloWo ...
 - NSMutableDictionary 排序问题
			
NSMutableDictionary 默认情况下是按字母的顺序进行排序的 (a-z)的默认排序如何自定义排序呢? 第一种,利用数组的sortedArrayUsingComparator调用 NSCo ...
 - linux截图工具
			
推荐:deepin-scrot 满足功能: 能够自定义快捷键(Ctrl+Alt+A) 小巧快速自定义选择区域进行截图 有简单的绘图功能 可以快速的保存到剪切版(双击图片) P.S.:双重截图