Danganronpa

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 406    Accepted Submission(s): 294

Problem Description
Chisa Yukizome works as a teacher in the school. She prepares many gifts, which consist of n kinds with a[i] quantities of each kind, for her students and wants to hold a class meeting. Because of the busy work, she gives her gifts to the monitor, Chiaki Nanami. Due to the strange design of the school, the students' desks are in a row. Chiaki Nanami wants to arrange gifts like this:

1. Each table will be prepared for a mysterious gift and an ordinary gift.

2. In order to reflect the Chisa Yukizome's generosity, the kinds of the ordinary gift on the adjacent table must be different.

3. There are no limits for the mysterious gift.

4. The gift must be placed continuously.

She wants to know how many students can get gifts in accordance with her idea at most (Suppose the number of students are infinite). As the most important people of her, you are easy to solve it, aren't you?

 
Input
The first line of input contains an integer T(T≤10) indicating the number of test cases.

Each case contains one integer n. The next line contains n (1≤n≤10) numbers: a1,a2,...,an, (1≤ai≤100000).

 
Output
For each test case, output one line containing “Case #x: y” (without quotes) , where x is the test case number (starting from 1) and y is the answer of Chiaki Nanami's question.
 
Sample Input
1
2
3 2
 
Sample Output
Case #1: 2
 
Author
UESTC
 
Source
 
 
 
解析:贪心。
 
 
 
#include <cstdio>
#include <algorithm>
using namespace std; int a[15]; int main()
{
int t, n, cn = 0;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
int sum = 0, m = 0;
for(int i = 0; i < n; ++i){
scanf("%d", &a[i]);
sum += a[i];
m = max(m, a[i]);
}
int res = min(sum/2, (sum-m)*2+1);
printf("Case #%d: %d\n", ++cn, res);
}
return 0;
}

  

HDU 5835 Danganronpa的更多相关文章

  1. HDU 5835 Danganronpa(弹丸论破)

     Danganronpa(弹丸论破) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  2. HDU 5835 Danganronpa (贪心)

    Danganronpa 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...

  3. HDU 5835 Danganronpa 贪心

    Danganronpa 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5835 Description Chisa Yukizome works as ...

  4. HDU 5835 Danganronpa (水题)

    题意:给定 n 个礼物有数量,一种是特殊的,一种是不特殊的,要分给一些人,每人一个特殊的一个不特殊,但是不特殊的不能相邻的,问最多能分给多少人. 析:是一个比较简单的题目,我们只要求差值就好,先算第一 ...

  5. [ An Ac a Day ^_^ ] hdu 5835 Danganronpa 令人发指

    这道题告诉我两个道理: 1.记得写case 要不挂死你 2.数据很水的时候 只有样例的这一种情况…… 原来数据可以这么水…… #include<stdio.h> #include<i ...

  6. Hdu 5384 Danganronpa (AC自动机模板)

    题目链接: Hdu 5384 Danganronpa 题目描述: 给出n个目标串Ai,m个模式串Bj,问每个目标串中m个模式串出现的次数总和为多少? 解题思路: 与Hdu 2222  Keywords ...

  7. 【HDU 5835】Danganronpa(分配礼物)

    10种礼物,每种有ai个,每个小朋友分两个礼物,其中普通礼物要求相邻两人的不能一样,求最多分给几个小朋友. sum/2是最多的情况.什么时候发不了那么多,就是当max很大,无论怎么发,都发不完max. ...

  8. hdu 5384 Danganronpa

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=5384 思路:没学自动机时以为是道KMP然后就tle了好几把,AC自动机模板题 #include<cs ...

  9. HDU 5384——Danganronpa——————【AC自动机】

    Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tot ...

随机推荐

  1. CodeForces369C On Changing Tree

    昨天的CF自己太挫了.一上来看到A题,就有思路,然后马上敲,但是苦于自己很久没有敲计数的题了,许多函数都稍微回忆了一阵子.A题的主要做法就是将每个数质因数分解,统计每个质因子的个数,对于每个质因子pi ...

  2. Android 虚拟机安装SD卡

    在cmd命令行下,进入platform-tools目录下.   1.创建sdcard   mksdcard -l mycard 256M E:\android\myCards\mysdcard.img ...

  3. QAQ高精度模板笔记√

    #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #i ...

  4. sql sever 2000

    sql sever 2000安装图解 浏览:15396 | 更新:2011-12-14 16:33 1 2 3 4 5 6 7 分步阅读 做为入门系统管理员,sqlsever2000是必会项目,因为市 ...

  5. CF 353C Find Maximum #205 (Div. 2)

    #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ]; ] ...

  6. ibatis框架的sqlmapclient接口

    SqlMapClient,是iBatis中的重要接口,这个接口涉及到对SQL映射的执行和批处理. 现在,就先了解它的对query开头方法的定义. 首先是 queryForList 方法: //指定SQ ...

  7. java:异常处理

    异常:编译正常,但运行出错,会中断正常指令流 RuntimeException:运行时异常 分为:uncheck exception.和check exception(除了RuntimeExcepti ...

  8. 关于use-default-filters的一个问题

    use-default-filters=true 默认行为会自动扫描所有注解

  9. OpenCV在Android平台上的应用

    今年8月份, OpenCV 2.3.1发布了. 虽然从2.2开始, OpenCV就号称支持Android平台, 但真正能让OpenCV在Android上运行起来还是在2.3.1版本上. 在这个版本上, ...

  10. iosblock用法

    看了很多的block用法,还是小糊涂. 最后还是自己尝试吧. #import "FirstViewController.h" @interface FirstViewControl ...