HDU-5835-Danganronpa【2016CCPC网络赛】

原创 2016年08月30日 11:19:47

1004-Danganronpa


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

题目链接:HDU-5835

题目大意:有n种礼物,给出每种礼物的个数,相邻同学的礼物不能相同,问有多少人个同学能拿到符合要求的礼物。

以下是代码:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int cas = 1;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int sum = 0,num;
        for (int i = 0; i < n; i++)
        {
            cin >> num;
            sum += num;
        }
        printf("Case #%d: %d\n",cas++,sum/2);
    }
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

HDU 5835 Danganronpa

将n种礼物分配到一排桌子上,每个桌子上两种礼物,一个普通礼物,一个神秘礼物,相邻桌子上的普通礼物不能相同。问最多可以分配给多少个学生...

[2016CCPC 网络预选赛] HDU5834 记忆化搜索

题意给一棵树,每个结点有宝贝,通过每条路要付费,问从每个点出发的最大收益。思路宝贝只能拿一次,边每次过都要交费。一个点的最大收入显然就是去几个路费小的子树拿宝贝,然后走一条不归路。那么就来两遍搜索,第...
  • SongBn
  • SongBn
  • 2016年08月14日 23:28
  • 385

HDU-5833-Zhu and 772002【2016CCPC网络赛】【高斯消元】

1002-Zhu and 772002 题目大意:给出n个数字,问有多少种方式取(1~n)个数字使得成为一个完美平方数 题目思路: 求完全平方数,质因子的范围也知道,所以我们可以对每个质因子列出一个模...

HDU 5835 Danganronpa

...神特么弹丸论破 有n种礼物,每种礼物a[I]个,现在有一排无限长的桌子,要往上面放礼物,每个桌子放两个礼物,第一个礼物要求相邻的桌子第一个礼物是不同的,第二个礼物没有这个要求,可以随便选一种礼...
  • oldFlag
  • oldFlag
  • 2016年08月14日 19:18
  • 132

hdu 5835 虹软杯 1004 Danganronpa (贪心)

贪心,和强手组队就是要沦为读题专人。

HDU 5835 Danganronpa (贪心)

Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To...

hdu 5835 Danganronpa(贪心,优先队列)

Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To...
  • acm_cxq
  • acm_cxq
  • 2016年08月14日 23:32
  • 235

hdu 5918 Harmonic Value Description 2016ACM/CCPC长春赛区现场赛H

Problem Description Mr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a number p. He wan...
  • lqybzx
  • lqybzx
  • 2016年10月08日 19:26
  • 253

【HDU5926 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 E】【水题】Mr. Frog’s Game 连连看

Mr. Frog’s Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)...

HDU5833(2016CCPC网赛)——Zhu and 772002(异或方程组,素数分解)

Zhu and 772002 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:HDU-5835-Danganronpa【2016CCPC网络赛】
举报原因:
原因补充:

(最多只允许输入30个字)