ZOJ Problem Set - 1200 (Mining)
2014-08-11 11:25
411 查看
//这是一道关于优先队列(堆)的题,题目并不是很难,但是通过的只有18.10%;
//题目: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1200
#include<iostream>
#include<vector>
#include<functional>
#include<queue>
using namespace std;
priority_queue<int, vector<int>, greater<int> > rq; //定义一个最小堆,用来表示每个机器人到达矿场的时间
int S, W, C, K, M;
int main()
{
int i, n, a;
while (cin >> S >> W >> C >> K >> M)
{
while (!rq.empty())
{
rq.pop();
}
n = 9999 / C + 1;
for (i = 1; i <= K; i++)
{
rq.push(i*M + S);
}
int time = rq.top(); //time表示当前一个机器人进入矿场的时间。
for (i = 0; i < n-1; i++)
{
rq.pop();
rq.push(2 * S + time+W);
if (rq.top() - time <= W)
{
time += W;
}
else
{
time = rq.top();
}
}
time += S+W;
cout << time << endl;
}
return 0;
}
//题目: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1200
#include<iostream>
#include<vector>
#include<functional>
#include<queue>
using namespace std;
priority_queue<int, vector<int>, greater<int> > rq; //定义一个最小堆,用来表示每个机器人到达矿场的时间
int S, W, C, K, M;
int main()
{
int i, n, a;
while (cin >> S >> W >> C >> K >> M)
{
while (!rq.empty())
{
rq.pop();
}
n = 9999 / C + 1;
for (i = 1; i <= K; i++)
{
rq.push(i*M + S);
}
int time = rq.top(); //time表示当前一个机器人进入矿场的时间。
for (i = 0; i < n-1; i++)
{
rq.pop();
rq.push(2 * S + time+W);
if (rq.top() - time <= W)
{
time += W;
}
else
{
time = rq.top();
}
}
time += S+W;
cout << time << endl;
}
return 0;
}
相关文章推荐
- ZOJ Problem Set–1970 All in All
- ZOJ Problem Set - 2987 Misspelling
- ACM ZOJ Problem Set - 1403 Safecracker
- ZOJ Problem Set - 1414||Number Steps
- ZOJ Problem Set - 1402 Magnificent Meatballs
- ZOJ Problem Set - 1006 Do the Untwist
- ZOJ Problem Set - 3713
- ZOJ Problem Set - 1201 Inversion
- ZOJ Problem Set - 1002
- ZOJ Problem Set – 1056 The Worm Turns
- ZOJ Problem Set - 3490 String Successor(字符串模拟)
- ZOJ Problem Set - 1003
- ZOJ Problem Set - 1078
- ZOJ Problem Set - 1755 Clay Bully
- ZOJ Problem Set - 1004
- ZOJ Problem Set - 3938 (模拟)
- ZOJ Problem Set - 1970 All in All
- ZOJ Problem Set - 1012
- ZOJ Problem Set - 3938 Defuse the Bomb
- ZOJ Problem Set - 2947 Abbreviation