/*
Gu Jian Qi Tan -------------------------------------------------------------------------------- Time Limit: 2 Seconds Memory Limit: 65536 KB -------------------------------------------------------------------------------- Gu Jian Qi Tan is a very hot Chinese RPG in this summer vacation. SuSu is the most important role in the game. When SuSu first meet the ancient dragon QianYu, he will have a very difficult battle with QianYu. In order to resist QianYu's powerful attack, SuSu must make a special armor, which needs some precious materials ( We call it "Ice Heart" ). Before this legend fight, SuSu must pass M dangerous labyrinth in order. In each labyrinth, there is a very powerful monster (We usually call it "BOSS") keeping watching the exit. So SuSu must defeat each BOSS if he wants to leave each labyrinth. When SuSu is fighting with a BOSS, he must attack its main body to kill it. however, some BOSS may have one or more special position of its body (such as wings, hands, weapons). SuSu can choose to attack these special positions and he will get one Ice Heart if he break the defence of one special position. Of course SuSu can choose not to attack special positions but just attack the BOSS's main body (in this situation, he can still kill the BOSS, but he cannot get Ice Heart). The defence of all special positions are so strong that normal attack are not available. SuSu must use magic skill to attack it. Once he uses a magic skill, his mana point will decrease to 0. In order to recover mana point, he can eat a special food "Dan Gui Hua Gao" (a kind of cake). In each labyrinth, SuSu can collect some cakes by killing small monsters. When he fights with a BOSS, his initial mana point will be 0. Different BOSS may have different amount of special positions, and the defence of different position may also be different ( that is, some positions may need just one magic attack but some may need to be attacked many times )
Notice: cakes in previous labyrinth can be accumulated and brought to later labyrinth. Can you tell how many Ice heart can SuSu get at most? Input
The first line of the input is a single integer T (T <= 20) indicating the number of test cases.
In each case, fisrt there is a line containing one integer M ( M <= 1000) indicating the number of labyrinth.
Then M lines follow. In the ith line, first there is an integer n (n <= 1000) indicating the amount of special positions this BOSS has.
Then followd by n integers, the ith integer ( no more than 20 ) indicating the amount of magic attacks SuSu must use to break the ith special position.
Finally there is a line containing M integers, the ith integer ( no more than 20 ) indicating how many cakes SuSu can collect in the ith labyrinth. Output
For each case, output one line, containing the maximum number of Ice Heart SuSu can get. Sample Input
1
2
1 10
2 1 2
10 0 Sample Output
2 --------------------------------------------------------------------------------
Author: HUANG, Qiao
Contest: ZOJ Monthly, November 2010 Submit Status
题意:有m层迷宫,每层迷宫有一只怪物,怪物有ni个“特别的位置”,
攻打每个位置需要cost[i]点魔,打完后可获得一个ice heart,
到达每层你就会有相应数量的魔,
每层的魔可以累加使用,让你求出最多获得几个ice heart。 解法:,尽可能地占下所有的ice heart,
如果占下某个ice heart时将当前积累的Cake消耗成了负数,
则放弃之前取得的一个消耗Cake最大的ice heart。 贪心。对于一个ice heart,如果当前cake数大于或等于该ice heart的消耗,
则直接取得,如果不,则用前面消耗的最大cake的与当前ice heart比较,
当前ice heart消耗小些,则交换,赚一点cake,否则不换。用一个最大堆维护即可。 */
#include <iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#define maxn 2600 int main()
{
int T,t,M,n,i,j,sum,k;
scanf("%d",&T);
while(T--)
{
vector<int>a[maxn];
//开始把它定义成全局变量,没想到没有清空,报错
//放在这里时每次循环会从新定义,可以不清空
priority_queue<int> q;
scanf("%d",&M);
for(i=; i<M; i++)
{
scanf("%d",&n);
for(j=; j<n; j++)
{
scanf("%d",&t);
a[i].push_back(t);
} }
sum=;
k=;
for(i=; i<M; i++)
{
scanf("%d",&t);
sum+=t;
for(j=; j<a[i].size(); j++)
{
sum-=a[i][j];
q.push(a[i][j]);
k++; }
while(sum<)
{
sum+=q.top();
q.pop();
k--;
} }
/* for(i=0;i<M;i++)
{
for(j=0;j<a[i].size();j++)
cout<<a[i][j]<<" ";
cout<<endl;
}*/
while(!q.empty())q.pop();
printf("%d\n",k);
}
return ;
}

zoj-3433-Gu Jian Qi Tan的更多相关文章

  1. zoj3433(贪心+优先队列)

    Gu Jian Qi Tan Time Limit: 2 Seconds      Memory Limit: 65536 KB Gu Jian Qi Tan is a very hot Chines ...

  2. php获取汉字的拼音 拼音首字母

    /***获取汉字的拼音*/function pinyin($s, $isfirst = false) { static $pinyins; $s = trim($s); $len = strlen($ ...

  3. [C#] 汉字转拼音,支持多音字

    这份代码大概不是严格意义上正确的,但是一般场景用用应该没问题. using System; using System.Collections.Generic; using System.Linq; u ...

  4. [Erlang20]一起攻克Binary

    第一次看到Joe Armstong的<Erlang 程序设计>里面对Binary的描述时,觉得这个东西好复杂,语法这么奇特(我觉得是Erlang语法中最不好懂的部分); 然后在项目中:Bi ...

  5. ZOJ 3794 Greedy Driver

    两次SPFA 第一关找:从1没有出发点到另一个点的多少是留给油箱 把边反过来再找一遍:重每一个点到终点最少须要多少油 Greedy Driver Time Limit: 2 Seconds       ...

  6. ZOJ 3635 Cinema in Akiba[ 大规模阵列 ]

    门户:problemCode=3635">ZOJ 3635 Cinema in Akiba Time Limit: 3 Seconds      Memory Limit: 65536 ...

  7. ZOJ 3228 Searching the String(AC自动机)

    Searching the String Time Limit: 7 Seconds      Memory Limit: 129872 KB Little jay really hates to d ...

  8. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  9. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

随机推荐

  1. Windows 2003/XP 连接vmware 5.5错误

    参考文章:http://www.mamicode.com/info-detail-7253.html 补丁下载地址参考: http://support.microsoft.com/hotfix/KBH ...

  2. django2中文界面

    设置了中文语言 zh-hans后,django2默认页面是中文的. 看起来也不错哦. 创建django2超级管理员: createsuperuser 创建管理员后,就可以登录后台了. 注册用户user ...

  3. [置顶] 不再迷惑,也许之前你从未真正懂得 Scroller 及滑动机制

    学习本来就是从困惑中摸索问题答案的过程,能够描述出来问题就已经成功了一半.只要发现了困扰你的东西是什么,那么你就离解答出来不远了.----肯尼斯 R. 莱伯德 一直以来,Android 开发中绕不过去 ...

  4. URL中不应出现汉字

    浏览器会在跳转时,先将汉字编译成 Unicode,然后跳转,导致hash值改变两次,相当于history 中 加入了两次URL 

  5. http协议知识整理

    HTTP 协议 作为web开发人员,了解一些http协议的知识很有必要.本文简单介绍了HTTP协议的知识,若有错误的地方,望大家指正. 1.HTTP协议是什么? http协议是一个应用层的协议.规定了 ...

  6. Windows批处理笔记

    1. 路径类相关代号 %i提取第i个命令选项,例如%1提取第1个option,i可以取值从1到9 %~0: 取文件名(名+扩展名) %~f0:取全路径 %~d0:取驱动器名 %~p0:只取路径(不包驱 ...

  7. hiho1523 数组重排2

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个1-N的排列A1, A2, ... AN,每次操作小Hi可以选择一个数,把它放到数组的最左边. 请计算小Hi最少进 ...

  8. AngularX Http服务总结

    自己经常用的方式: 1.首先看httpModule Angular2的http访问经常采用两种方式: 共同点:导入相应的Module import {Http, RequestOptions, Res ...

  9. CODEVS3013 单词背诵 【Hash】【MAP】

    CODEVS3013 单词背诵 题目描述 Description 灵梦有n个单词想要背,但她想通过一篇文章中的一段来记住这些单词. 文章由m个单词构成,她想在文章中找出连续的一段,其中包含最多的她想要 ...

  10. Ubuntu12.04无法使用vim系统剪贴板解决方法

    以前在 vim 下工作需要在 vim 和其它的编辑器之间复制东西,使用 Shift + Ctrl + v/c.感觉这样很不方便,今天在网上搜索了以下可以用 “+y/p,但是自己实验怎么也不行,在命令模 ...