链接:http://acm.tju.edu.cn/toj/showp4120.html4120.   Zombies VS Plants


Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 268   Accepted Runs: 36


tmeteorj recently is interested in a game Plants VS Zombies like following picture.

And his brain hole is opened so he want to you to solve this problem.
Your role is zombies' manager, and your task is place enough zombies to eat all plants on each line.
The rules are as follows:
1.Each zombies has health point from 1 to infinity.
2.Each plants has its attack point which we will tell you and will not greater than 1000.
3.All plants are so afraid of zombies, so if a plant's attack point is not greater than it's line's zombie's HP, this plant will be scared silly. So its attack point will become zero.
4.Zombies eat plants from right to the left.
5.You can place any number of zombies on each line.
Your task is to calculate the minimal total zombies' HP you need to place in order to eat all plants.

INPUT

First line, there will a number T(T≤10), means the test case of this problem.
After this, there will be a number n(n≤100), means there are n lines in the yard.
Each line contains several plants' attack points. The plants' number will not greater than 100.
There may be some blanks in anywhere.

OUTPUT

For each case, print the minimal HP for the question.

Sample Input

3
2
1 2 3 4 5
2 3 4 5
1
1 2 3 4 5
2
1 2 3 4 5 6
1 2

Sample Output

10
5
8
/*
遇见过的最坑的题目,主要坑点在与输入会在各处出现空格
听说还可能出现一行1500空格....
所以得用好getchar,这是关键
*/
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main()
{int i,j,k,zhi,fu,flag,N,T;char ch;int sum,mx ;scanf("%d",&T);while(T--){scanf("%d",&N);while(getchar()!='\n');sum=0;for(int i=1;i<=N;i++){flag=0;zhi=0;fu=1;mx=1;while(1){ch=getchar();if(ch=='-'){flag=1;fu=-1;}else if(ch==' '){mx=max(mx,fu*zhi);fu=1;zhi=0;}else if(ch=='\n'){if(flag){mx=max(mx,fu*zhi);fu=1;zhi=0;}else mx=0;break;}else{zhi=zhi*10+ch-'0';flag=1;}}sum+=mx;}printf("%d\n",sum);}return 0;
}

转载于:https://www.cnblogs.com/Basasuya/p/8433779.html

TOJ 4120 Zombies VS Plants相关推荐

  1. 【课程设计】僵尸大战植物 Zombies vs.Plants

    游戏图鉴 游戏背景 僵尸成功入侵了戴夫家并吃掉了他的脑子 不过为了复仇,花园中的植物都会从地上长出来阻止凶手的离开 而作为僵尸头领的你需要合理的安排逃跑路线使得僵尸尽可能地逃离花园 游戏模式 冒险模式 ...

  2. BZOJ1565:[NOI2009]植物大战僵尸——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=1565 https://www.luogu.org/problemnew/show/P2805 Pla ...

  3. BZOJ1565[NOI2009]植物大战僵尸——最大权闭合子图+拓扑排序

    题目描述 Plants vs. Zombies(PVZ)是最近十分风靡的一款小游戏.Plants(植物)和Zombies(僵尸)是游戏的主角,其中Plants防守,而Zombies进攻.该款游戏包含多 ...

  4. bzoj1565【NOI2009】植物大战僵尸(最小割)

    题目描述 Plants vs. Zombies(PVZ)是最近十分风靡的一款小游戏.Plants(植物)和Zombies(僵尸)是游戏的主角,其中Plants防守,而Zombies进攻.该款游戏包含多 ...

  5. ZRX的网络流题目总结

    PARTI 最大流 例1:bzoj 3931 Description 路由是指通过计算机网络把信息从源地址传输到目的地址的活动,也是计算机网络设计中的重点和难点.网络中实现路由发的硬件设备称为路由器. ...

  6. NOIP 好题推荐(DP+搜索+图论)POJ ZOJ

    NOIP好题推荐(DP+搜索+图论)POJ ZOJ 1370 Gossiping (数论->模线性方程有无解的判断)+(图论->DFS)  1090 Chain ->格雷码和二进制码 ...

  7. zoj4062 Plants vs. Zombies 二分+模拟(贪心的思维)

    题目传送门 题目大意:有n个植物排成一排,标号为1-n,每株植物有自己的生长速度ai,每对植物浇一次水,该株植物就长高ai,现在机器人从第0个格子出发,每次走一步,不能停留,每一步浇一次水,总共可以走 ...

  8. Plants vs. Zombies(二分)

    文章目录 [Plants vs. Zombies](https://zoj.pintia.cn/problem-sets/91827364500/problems/91827370312) 题意 解题 ...

  9. 植物大战僵尸(Plants vs. Zombies)Mac版本

    游戏介绍 可怕的僵尸即将入侵你的家,唯一的防御方式就是你栽种的植物!武装你的植物,切换他们不同的功能,诸如强悍的豌豆射手或樱桃炸弹,更加快速有效的将僵尸阻挡在入侵的道路上.不同的敌人,不同的玩法构成五 ...

最新文章

  1. python count函数时间复杂度_Python(算法)-时间复杂度和空间复杂度
  2. 由一棵二叉树的先序序列和中序序列可唯一确定这棵二叉树
  3. Spring Task定时任务的配置和使用详解
  4. python 嵌入键值数据库_PupDB 一个用Python编写基于文件的简单键值数据库
  5. mysql数据库被黑客删除,您做好防范了吗?
  6. 重构—改善既有代码的设计
  7. PHP替换文本文件其中一行,使用PHP替换文本文件中的行
  8. 有用的Ant构建标签
  9. macOS 使用手册
  10. 一对一直播社交聊天程序: JAVA中的Socket源码概述
  11. MyCat分布式数据库集群架构工作笔记0019---高可用_单表存储千万级_海量存储_水平分表
  12. Vue.js 学习笔记 七 控制样式
  13. Node.js之Stream可读流readable
  14. 【TSP】基于matlab免疫算法求解31城市旅行商问题【含Matlab源码 1149期】
  15. 常微分方程之Kutta公式、Gill公式、隐式龙格库塔公式、半隐式龙格库塔公式、Milne方法、Hamming方法、不显含一阶导数的二阶微分方程的求解方法、非线性微分方程的差分法
  16. uniapp获取屏幕宽度的方式_Vue.js Uniapp 获取屏幕、元素的高度宽度
  17. 一个非常好用的免费图床
  18. 微信刷票怎么查实_怎么检查“微信公众平台投票”是否有刷票?
  19. c语言母亲节算法,用Excel推算母亲节日期,能理解最后一种算法的是高手!
  20. 云服务是什么?云服务能做什么?

热门文章

  1. ## 使用flex布局(多行,一行三个),换行后最后一行左右对齐问题
  2. 可以群发消息的微信营销软件
  3. 在Linux命令行终端中写python代码的简单操作
  4. 点到点的距离、点到直线的距离、点是否在直线上
  5. 在职研究生计算机科学与技术考研考哪些科目,计算机在职研究生考试科目
  6. MOOC(幕课)的到来!
  7. cod16显示服务器队列,使命召唤16战区
  8. 烤仔建工 | 来红浪漫和漂亮姐姐Yanelis K歌吧
  9. nslookup命令使用技巧
  10. [解决] 警告: 未来的版本中将会删除 NARGCHK。请改用 NARGINCHK 或 NARGOUTCHK。