poj 2336 Ferry Loading II ( 【贪心】 )】的更多相关文章

Ferry Loading II Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3704   Accepted: 1884 Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide…
2419: Ferry Loading II  Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 4            Accepted:3 Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their lar…
Ferry Loading II Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3763 Accepted: 1919 Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide line…
题目链接: Ferry Loading II Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3946   Accepted: 1985 Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a…
Ferry Loading Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1807   Accepted: 509   Special Judge Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run…
Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Cars drive onto the ferry from one end, the ferry cross…
双塔DP+输出路径. 由于内存限制,DP只能开滚动数组来记录. 我的写法比较渣,但是POJ能AC,但是ZOJ依旧MLE,更加奇怪的是Uva上无论怎么改都是WA,其他人POJ过的交到Uva也是WA. #include<cstdio> #include<cstring> #include<cmath> #include<stack> #include<algorithm> using namespace std; ][+]; struct P { i…
题目描述 Description Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Cars drive onto the ferry from one end, the ferry…
Ferry Loading IIITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 463 Accepted Submission(s): 110 Problem DescriptionBefore bridges were common, ferries were used to transport cars across rivers. Ri…
题意: 给你一个n行m列由'#'和'.'构成的矩阵,你需要从(1,1)点走到(n,m)点,你每次只能向右或者向下走,且只能走'.'的位置. 你可以执行操作改变矩阵: 你可以选取两个点,r0,c0;r1,c1.以(r0,c0)为小矩阵左上角坐标,以(r1,c1)为小矩阵右下角坐标.你要把这个小矩阵中的所有字符反转(也就是原来是'#'的,要变成'.',原来是'.'的,要变成'#') 题解: 对于样例 3 3 .## .#. ##. 我们可以看成反转之后的矩阵最终从(1,1)走到(n,m)的只有一条路…
Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one sha…
http://poj.org/problem?id=1065 题意比较简单,有n跟木棍,事先知道每根木棍的长度和宽度,这些木棍需要送去加工,第一根木棍需要一分钟的生产时间,如果当前木棍的长度跟宽度 都大于前一根木棍,那么这根木棍不需要生产时间,问你最少的生产时间是多少? 首先可以贪心,先按长度 l排序,如果l相同,按宽度w排序. 从i=0开始,每次把接下来的i+1  -  n-1 的没有标记并且长度和宽度大于等于i这根木棍的长度和宽度标记起来. #include<cstdio> #includ…
The King Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7499   Accepted: 4060 Description Once upon a time in a country far away lived a king and he had a big kingdom. He was a very clever king but he had one weakness -- he could count…
POJ 2393 题意: 每周可以生产牛奶,每周生产的价格为Ci,每周需要上交的牛奶量Yi,你可以选择本周生产牛奶,也可选择提前几周生产出存储在仓库中(仓库无限大,而且保质期不考虑),每一周存仓库牛奶需要花费S元,让你求出所有周的需求量上交的最少花费. 分析: 因为第 i 周的奶酪,可以在第 i 周生产,也可以在前几周生产,然后储存.通过把s转化为花费,跟原有花费去比较,取一个最小值,这样从头到尾,每一周都可以取得一个花费的最小值.贪心求解. #include<cstdio> #include…
题目地址:http://poj.org/problem?id=1065 Sample Input 3 5 4 9 5 2 2 1 3 5 1 4 3 2 2 1 1 2 2 3 1 3 2 2 3 1 Sample Output 2 1 3 题目抽象:给你一个序列,序列的每个元素包含两个值(x,y).现在希望找到最少数目的条件序列.条件序列是这样的:cur.x<=(cur+1).x && cur.y<=(cur+1).y满足条件的序列的最少的数目是多少?代码: #include…
Gopher II Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6675   Accepted: 2732 Description The gopher family, having averted the canine threat, must face a new predator. The are n gophers and m gopher holes, each at distinct (x, y) coor…
Description Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the day into T shifts (1 <= T <= 1,000,000), t…
id=3122">[POJ 3122] Pie 分f个派给n+1(n个朋友和自己)个人 要求每一个人分相同面积 但不能分到超过一个派 即最多把一整个派给某个人 问能平均分的最大面积 二分平均面积 下界0 上界最大的一份派的面积 推断条件从大派開始分(保证尽量满足)假设能分出n+1份 这样的分法就合适 下界上移 最后输出下界就可以 注意二分推断上下界用esp 否则超时 从大到小分派是一种贪心策略 太小的派能够扔掉 但从小開始分有可能第一个派就分不出这么大 不排序也可遇到小派跳过 最后推断 代…
带来两题贪心算法的题. 1.给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下面两个操作:1.从S的头部删除一个字符,加到T的尾部.2.从S的尾部删除一个字符,加到T的尾部.求你任意采取这两个步骤后能得到的最小字符串T 2.直线上有N个点,点i的位置是xi,这N个点中选择若干个做上标记,对于每个点,在他们距离为R的区域内必须带有标记点,求在满足这个条件的情况下,所需要标记点的最少个数. 1.POJ 3617 Best Cow Line http://poj.…
地址 http://poj.org/problem?id=3069 题解 题目可以考虑贪心 尽可能的根据题意选择靠右边的点 注意 开始无标记点 寻找左侧第一个没覆盖的点 再来推算既可能靠右的标记点为一轮 我最开始就是轮次的操作理解错误 结果wa了 ac代码如下 #include <iostream> #include <vector> #include <algorithm> using namespace std; /* poj3069 题目大意:一个直线上有N个点.…
题意:在平面直角坐标系中给你N个点,stan和ollie玩一个游戏,首先stan在竖直方向上画一条直线,该直线必须要过其中的某个点,然后ollie在水平方向上画一条直线,该直线的要求是要经过一个stan画的竖线经过的点.这时候平面就被分割成了四块,两个人这时候会有一个得分,stan的得分是平面上第1.3象限内的点的个数,ollie的得分是平面上第2.4象限内的点的个数,在统计的时候所画线上的点都不计算在内.Stan的策略是,自己画一条竖线之后,Ollie有很多种选择,而ollie当然是让自己的越…
http://poj.org/problem?id=3262 开始一直是理解错题意了!!导致不停wa. 这题是农夫有n头牛在花园里啃花朵,然后农夫要把它们赶回棚子,每次只能赶一头牛,并且给出赶回每头牛需要的时间和牛在花园每分钟吃多少花朵,问你怎么安排让损失最小. 这题单独按time和eat排序都不行,得按它们的比率来排,如果是选择eat/time  则从大到小排,time/eat则从小到大排,但是不会严格证明. #include <iostream> #include <cstdio&g…
http://poj.org/problem?id=3190 有n头挑剔的奶牛,只会在一个精确时间挤奶,而一头奶牛需要占用一个畜栏,并且不会和其他奶牛分享,每头奶牛都会有一个开始时间和结束时间,问至少需要多少个 畜栏  并且输出奶牛 i 在哪个畜栏 内挤奶. 首先应该对奶牛以开始时间从小到大排序,然后每次在开始的奶牛中选择结束时间最小的奶牛,这就需要用优先队列.看是否可以用这个畜栏,可以就加入到队列中,不可以就重新加一个畜栏. #include <iostream> #include <…
题意:给定一行字符串,让你把它变成字典序最短,方法只有两种,要么从头部拿一个字符,要么从尾部拿一个. 析:贪心,从两边拿时,哪个小先拿哪个,如果一样,接着往下比较,要么比到字符不一样,要么比完,也就是说从头部和尾部拿都一样,那么就随便拿一个了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <…
题目:http://poj.org/problem?id=3258 题意: 一条河长度为 L,河的起点(Start)和终点(End)分别有2块石头,S到E的距离就是L. 河中有n块石头,每块石头到S都有唯一的距离 问现在要移除m块石头(S和E除外),每次移除的是与当前最短距离相关联的石头, 要求移除m块石头后,使得那时的最短距离尽可能大,输出那个最短距离. 和3273差不多... #include <iostream> #include <cstdio> #include <…
 Saruman's Army Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3069 Appoint description:  System Crawler  (2015-04-27) Description Saruman the White must lead his army along a straight path fro…
uva10440:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1381 题意:题意:一条船能够一次最多渡n辆车过河,过河用t min,回来又要用t min.m辆车按照一定的计划到达岸边.现在要求最少 用多少时间就所有的船渡过河,以及用了最少多少次将所有. 题解:用贪心思想,最早运到对岸的时间,取决于最后来的…
Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, s…
Description Farmer John <= N <= ,) cows to <= T <= ,,), the first being shift and the last being shift T. Each cow is only available at some interval of times during the day for work on cleaning. Any cow that is selected for cleaning duty will…
题意:给定n个奶牛,FJ把奶牛i从其位置送回牛棚并回到草坪要花费2*t[i]时间,同时留在草地上的奶牛j每分钟会消耗d[j]个草 求把所有奶牛送回牛棚内,所消耗草的最小值 思路:贪心,假设奶牛a和奶牛b所处位置为, 交换前 ....(ta, da) (tb, db).... 交换后 ....(tb, db) (ta, da).... 设此前已消耗的时间为x,那么交换前消耗的草:x*da + (x+ta)*db 交换后消耗的草:x*db + (x+tb)*da 除非交换后的消耗相比交换前的小才交换…