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 ...
随机推荐
- (021)VMWare副虚拟磁盘和子虚拟磁盘id不匹配
问题:因为某种原因,修改了VM虚拟机的父磁盘内容,导致开机时出现如下错误: 父虚拟磁盘在子虚拟磁盘创建之后被修改过.父虚拟磁盘的内容 ID 与子虚拟磁盘中对应的父内容 ID 不匹配打不开磁盘“***. ...
- 浅析 Spark Shuffle 内存使用
在使用 Spark 进行计算时,我们经常会碰到作业 (Job) Out Of Memory(OOM) 的情况,而且很大一部分情况是发生在 Shuffle 阶段.那么在 Spark Shuffle 中具 ...
- .NET Core WebAPI Swagger使用
相对于普通的webapi而言,.net core webapi本身并不具备文档的功能,所以可以借助第三方插件:swagger,使用的话很简单. 步骤一. Nuget Packages安装,使用程序包管 ...
- Apache Cordova
http://cordova.apache.org/ Apache Cordova is a platformfor building native mobile applications using ...
- CF967D Resource Distribution
思路: 在一堆服务器中,资源最少的那一个是“瓶颈”,由此想到贪心思路. 首先对所有服务器按照资源数量c排序,再从头到尾扫描.对每个位置,根据x1和x2计算出两段连续的服务器集合分别分配给A任务和B任务 ...
- 使用laravel的Command实现搜索引擎索引和模板的建立
创建command,初始化es 创建成功后,可通过php artisan 查看到 php artisan make:command ESInit 安装guzzle composer require g ...
- PMP项目管理学习笔记(4)——项目整合管理
六个整合管理过程. 1.制定项目章程 一个新项目要完成的第一件事,就是项目章程的制定.这是授权你开展工作的文档.不过并不总是需要你介入,通常情况下会由赞助人交给你.如果没有项目章程,你就没有权利告诉你 ...
- ICEcoder显示汉字出现乱码的处理
在网上看到icecoder这个小东西,是一个基于web的编辑器,很不错.唯一的缺点是打开的文件中汉字会变成乱码. 经查看源代码,在lib/file-control.php中,第89行是: echo ' ...
- 洛谷 P1351 联合权值
题目描述 无向连通图G 有n 个点,n - 1 条边.点从1 到n 依次编号,编号为 i 的点的权值为W i ,每条边的长度均为1 .图上两点( u , v ) 的距离定义为u 点到v 点的最短距离. ...
- 【Hive】explain command throw ClassCastException in 2.3.4
参考:https://issues.apache.org/jira/browse/HIVE-21489 (一)问题描述: Hive-2.3.4 执行 explain select * from sr ...