POJ 1036 Rails 模拟堆栈】的更多相关文章

水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x==y)就是说接下来进站的正好是要出去的,那就直接让它A—>B 否则 if(C不空 && y=(最后进入C的火车)) 让车从C开出进入B  否则 if(x!=0)那么车 A—>C 否则  无解 #include<cstdio> #include<cstring>…
堆栈原理: 数组模拟堆栈: //数组模拟栈 class ArrayStack{ //栈顶 private int top = -1; private int maxSize; private int[] arrayStack; public ArrayStack(int maxSize){ this.maxSize = maxSize; arrayStack = new int[maxSize]; } //栈是否满 public boolean isFull(){ return top == m…
问题如下: 问题 B: Rails 时间限制: Sec 内存限制: MB 提交: 解决: [提交][状态][讨论版] 题目描述 There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was…
对列特点:先进先出.后进后出 用列表insert.pop模拟进队出队: >>> l = [] >>> l.insert(0,'p1') >>> l.insert(0,'p2') >>> l.insert(0,'p3') >>> l ['p3', 'p2', 'p1'] >>> l.pop() 'p1' >>> l.pop() 'p2' >>> l.pop() 'p…
题目链接:http://poj.org/problem?id=1363 题意:有一列火车,车厢编号为1-n,从A方向进站,向B方向出站.现在进站顺序确定,给出一个出站的顺序,判断出站顺序是否合理. 实际上是模拟栈的过程,而栈的特点是先进后出.另外一个麻烦的地方就是输入输出格式问题. 本题实现提供两种方法:没有用到STL栈和有用到STL栈 #include <iostream> // 法二:头文件多包含一个 #include <stack> using namespace std;…
1.链接: http://poj.org/problem?id=1363 http://bailian.openjudge.cn/practice/1363 2.题目: Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24612   Accepted: 9644 Description There is a famous railway station in PopPush City. Country ther…
http://poj.org/problem?id=1036 题意:N个土匪,伸缩门的范围是K, 时间T, 伸缩门在[0, k]范围内变动,每个单位时间可以不变伸长或者缩短一个单位.给出每个最烦到达的时刻,取得的成就,和肥胖程度.即如果伸缩门的长度和土匪的肥胖程度一样,即得到成就. 状态转移方程:dp[i][j]=max(dp[i-1][j],dp[i-1][j],dp[i-1][j+1])+a[i][j]; #include <cstdio> #include <cstring>…
题目代号:POJ 1363 题目链接:http://poj.org/problem?id=1363 题目原题: Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 34585   Accepted: 13434 Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The s…
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://poj.org/problem? id=3077 Description For a given number, if greater than ten, round it to the nearest ten, then (if that result is greater than 100) take the…
Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21728   Accepted: 8703 Description There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds we…