https://code.google.com/codejam/contest/6224486/dashboard#s=p1

题目不难,教训记终生

题目给了我们两种操作:1 所有人都吃一个,简记为消除操作 2 所有人不吃,把一个人的煎饼分给另一个人或者新来的人,简记为分配

明显,分配操作分给新来的人更有利,并且分配操作应该在消除操作之前

现在就是怎么分配的问题:

之前错误了两次,因为误认为直接对半分效率更高,但是对于 1 9这组数据,明显是分成 1 3 3 3比分成1 4 5 更优

所以,枚举分配操作之后的最大煎饼数i,然后分别计算把每个数量大于i的盘子里分到i所需多少次操作tmp.答案取最小的tmp+i即可

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e3+3;
const int maxp=1e3+3;
int n;
int num[maxp]; int main(){
freopen("data.in","r",stdin);
freopen("data.out","w",stdout);
int T;
scanf("%d",&T);
for(int ti=1;ti<=T;ti++){
scanf("%d",&n);
memset(num,0,sizeof(num));
int ans=0;
for(int i=0;i<n;i++){
int tmp;
scanf("%d",&tmp);
num[tmp]++;
ans=max(tmp,ans);
}
int mx=ans;
for(int i=1;i<=mx;i++){
int tmp=0;
for(int j=i+1;j<=mx;j++){
tmp+=(j+i-1)/i*num[j]-num[j];
}
tmp+=i;
ans=min(tmp,ans);
}
printf("Case #%d: %d\n",ti,ans);
}
return 0;
}

GCJ 2015-Qualification-B Infinite House of Pancakes 枚举,思路,误区 难度:3的更多相关文章

  1. dp - Google Code jam Qualification Round 2015 --- Problem B. Infinite House of Pancakes

    Problem B. Infinite House of Pancakes Problem's Link:   https://code.google.com/codejam/contest/6224 ...

  2. [C++]Infinite House of Pancakes——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

  3. [C++]Standing Ovation——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

  4. VK Cup 2015 - Qualification Round 1 D. Closest Equals 离线+线段树

    题目链接: http://codeforces.com/problemset/problem/522/D D. Closest Equals time limit per test3 secondsm ...

  5. codeforces VK Cup 2015 - Qualification Round 1 B. Photo to Remember 水题

    B. Photo to Remember Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/522/ ...

  6. Codeforces VK Cup 2015 - Qualification Round 1 D. Closest Equals 离线线段树 求区间相同数的最小距离

    D. Closest Equals Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/prob ...

  7. VK Cup 2015 - Qualification Round 1 A. Reposts [ dp DAG上最长路 ]

    传送门 A. Reposts time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  8. hdu 5358 First One 2015多校联合训练赛#6 枚举

    First One Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Tota ...

  9. 2015 多校联赛 ——HDU5371(manacher + 枚举)

    Sample Input 1 10 2 3 4 4 3 2 2 3 4 4   Sample Output Case #1: 9 要求找出一段数字. 将其分成3部分,第①和第②部分成回文字串,第②和第 ...

随机推荐

  1. [转载] 根据多年经验整理的《互联网MySQL开发规范》

    原文: http://weibo.com/p/2304181380b3f180102vsg5 根据多年经验整理的<互联网MySQL开发规范> 写在前面:无规矩不成方圆.对于刚加入互联网的朋 ...

  2. web设计经验<五>国外设计师总结的7个找灵感实用方法

    每个设计师不时会有创意灵感缺失.大脑一片空白的状态.盯着一个空白的屏幕,发愁着“好吧,我现在该做什么呢?该怎么做呢?”有些人喜欢静待,但这不是唯一的一个方法.焦虑的客户或者是你自己的不耐烦,都会让你无 ...

  3. 12/09 Oracle练习之新建表

  4. (四)主控板改IP,升级app,boot,mac

    给主控板升级boot要在boot界面进行,进入boot后,要先查看boot下ip和掩码是否和电脑ip(severip)在一个网段,不在的话要使用setenv命令设置ip地址和掩码.之后再输入upboo ...

  5. linux登录mysql

    mysql  -u 用户名 -p密码 mysql -u root -psqj888

  6. linux优先级、性能监控指令

    一.优先级 优先级的值=优先系数+nice值     优先系数由系统内核决定,不可更改 nice值可以手动更改,范围是 -20~19 优先级的值越低,优先级越高:优先级的值越高,优先级越低. 所以想调 ...

  7. 转 java List 与ArrasyList 区别

    转 List是一个接口,而ListArray是一个类, ListArray继承并实现了List. 为什么要用 List list = new ArrayList() ,而不用 ArrayList al ...

  8. China Brain Project: Basic Neuroscience, Brain Diseases, and Brain-Inspired Computing

    日前,中国科学院神经科学研究所.中国科学院脑科学与智能技术卓越创新中心.香港科技大学生命科学部和分子神经科学国家重点实验室.中国科技大学自动化研究所在 Cell 上联合发表了一篇概述论文<Chi ...

  9. ogre入门笔记

    ogre作为一款开源的非商业渲染引擎, 除去效率不谈, 其设计结构十分优雅, 值得游戏从业者拥有和学习.本篇笔记基于ogre v1.9. 1.代码模块 ogre的核心代码分布如下图: ogreMain ...

  10. canvas实现钟表

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...