Layton's Escape Time Limit: 2 Seconds      Memory Limit: 65536 KB Professor Layton is a renowned archaeologist from London's Gressenheller University. He and his apprentice Luke has solved various mysteries in different places. Unfortunately, Layton…
题目地址:http://www.51cpc.com/web/problem.php?id=1587 Summarize: 优先队列&贪心: 1. 按价值最高排序,价值相同则按完成时间越晚为先: 2. 使用数组记录时间节点是否有任务,时间节点从最晚倒序遍历: 3. 若此刻时间节点有任务,则从此时间节点往前推,直到某一刻无任务,否则放弃该任务: 附贪心代码: (此处并未使用优先队列,以vector代替) #include<iostream> #include<algorithm>…
以下代码可对结构体数组中的元素进行排序,也差不多算是一个小小的模板了吧 #include<iostream> #include<algorithm> using namespace std; struct node { int x; int y; bool operator<(const node &a) const//此操作是对操作符"<"进行重构 { return x < a.x;//对结构体数组x进行从大到小排序 // retur…
Buy and Resell Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2441    Accepted Submission(s): 924 Problem Description The Power Cube is used as a stash of Exotic Power. There are n cities numbe…
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day. Metropolis airport is the main transport hub of…
题目链接:http://poj.org/problem?id=2431 题目大意:一辆卡车,初始时,距离终点L,油量为P,在起点到终点途中有n个加油站,每个加油站油量有限,而卡车的油箱容量无限,卡车在行车途中,每走一个单位的距离消耗一个单位的油量,给定n个加油站距离终点的距离以及油存储量.问卡车是否能到达终点,如果可达,最少需要加多少次油,否则输出-1. 例: 输入: 44 45 211 515 1025 10 输出: 2 解题思路:采用贪心的思想,卡车当然在不加油的情况下走的越远越好了,而当它…
来源poj2431 A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Being rather poor drivers, the cows unfortunately managed to run over a rock and puncture the truck's fuel tank. The truck now leaks one unit of fuel every…
1350: To Add Which? Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 303     Solved: 134 Description There is an integer sequence with N integers. You can use 1 unit of cost to increase any integer in the sequence b…
链接:https://ac.nowcoder.com/acm/contest/558/C来源:牛客网 小猫在研究二元组. 小猫在研究最大值. 给定N个二元组(a1,b1),(a2,b2),…,(aN,bN),请你从中选出恰好K个,使得ai的最小值与bi的最小值之和最大. 请输出ai的最小值与bi的最小值之和 输入描述: 第一行两个正整数N,K,表示二元组数量与需要选的数量. 接下来N行,第i行两个正整数ai,bi. 输出描述: 一行一个正整数,表示最大的a_i的最小值与b_i的最小值之和. 示例…
题意:最近,减肥失败的湫湫为发泄心中郁闷,在玩一个消灭免子的游戏.游戏规则很简单,用箭杀死免子即可.箭是一种消耗品,已知有M种不同类型的箭可以选择,并且每种箭都会对兔子造成伤害,对应的伤害值分别为Di(1 <= i <= M),每种箭需要一定的QQ币购买.假设每种箭只能使用一次,每只免子也只能被射一次,请计算要消灭地图上的所有兔子最少需要的QQ币. 链接:点我 贪心在能杀死某个兔子的箭里选择价格最小的 一开始直接两个for,tle,看了别人代码之后才知道用优先队列 #include<cs…