Destroy the Well of Life HDU - 1692
来源:互联网 发布:java短链接 编辑:程序博客网 时间:2024/06/06 01:31
题意:
引爆生命之泉,手动引爆能量为p[i] ,里面的水会流向下一个泉,如果当前水+流的水>容量,生命之泉就被动引爆。
注意:
枚举每一个第一次引爆的泉水位置时候特判一下第一个是否比当前最小的还小
#include <iostream>#include <stdio.h>#include <cstring>#include <algorithm>#include <queue>#define maxn 200005using namespace std ;int w[maxn];int l[maxn];int p[maxn];int main(){ int T; scanf("%d",&T); for(int Case=1;Case<=T;Case++) { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d%d",&w[i],&l[i],&p[i]); int sum=0,ans=p[n],por=0; for(int i=1;i<=n;i++) { sum=w[i]; por=p[i]; if(por<ans) for(int j=i+1;j<=n;j++) { if(sum+w[j]<=l[j]) { por+=p[j]; if(por>=ans) break; } sum+=w[j]; } ans=min(por,ans); } printf("Case %d: Need to use %d mana points.\n",Case,ans); } return 0;}
0 0
- hdu 1692 Destroy the Well of Life
- Destroy the Well of Life HDU - 1692
- HDU 1692 Destroy the Well of Life-卡时间-(枚举+剪枝)
- hdu 1692 Destroy the Well of Lif…
- The order of life!
- The wholeness of life
- the Art of Life
- The Wholeness of Life
- The Destroy/Create Cycle of Activities
- the 50 symbols of life
- feeling of the new life
- YT14-HDU-The snail climb well
- The Secret Life Of The Finalizer
- Is Romantic Life the Foundation of Marriage?
- The Best Time of My Life
- The ABCs of Living a Happy Life
- The ABCs of Living a Happy Life
- The Life Cycle of a JSP Page
- [bigdata-003]在cdh 5.7下 用sqoop1将mysql数据库数据导入到hdfs的方式
- 模拟电路学习笔记
- HBase总结(十四)LINUX下用Eclipse构建HBase开发环境
- 机器学习方法:使用Apriori算法和FP-growth算法进行关联分析(Python版)
- 数组中两个字符串的最小距离
- Destroy the Well of Life HDU - 1692
- Android Studio插件整理
- wpf数据库连接登陆案例
- poj1258 Agri-Net 最小生成树
- Eclipse中编写Java调用C代码
- 观察者模式
- C# using 三种使用方式
- 二维码操作工具类
- nginx+php+gitblog