2673:Kicc Wants to Move a Mountain!

2673:Kicc Wants to Move a Mountain!
查看 提交 统计 提示 提问
总时间限制: 1000ms 内存限制: 65536kB
There is a huge mountain outside Kicc's house, and Kicc has to climb the mountain every time he wants to go out. It costs him a lot of time and he wants to change the situation. Yes, he figures out a good idea - to move the mountain away! But there is a problem. There are some wild animals not too far away from the mountain. Kicc will make noises when digging or moving the stones. If the animals hear the sound made by Kicc, they will come closer. If an animal reaches the mountain and sees Kicc, the animal will eat Kicc immediately. But the animals are stupid - when they do not hear the sound, they will go back along the exact route they come to the mountain until they are in the place where they start. When they hear the sound again, they will come to the mountain again no matter where they are. In this situation, Kicc has to stop sometimes before the first animal arrives to avoid being eaten. You should notice that as soon as the animal arrive in the mountain, Kicc will be eaten, no matter he stops his work or not.

Kicc has t units of time per day and he can handle x units of stones in one unit of time (This action will make noises). There are m animals near the mountain. The i-th animal stays away the mountain with di units of distance and can run si units of distance in one of unit time. Kicc wants to know the most amount of stones he can handle every day (You can assume the amount of the stones in the mountain is infinite). To make it easier, you may assume that Kicc can work or rest for only integer units of time, for example, 1 unit of time, or 2 units of time, or 3 units of time, and so on.
The first line contains an integer t (0 <= t < 1000000), and an integer x (0 < x < 10). The second line contains a single integer m (0 <= m < 1000). There are m lines following the second line, each has 2 integers di (0 < di < 1000000) and si (0 < si < 1000000).
The output should contain a single integer which means the most amount of stones Kicc can move away in one day.
100 5
1000 5
100 1


动物的跑动距离应该为di-1,否则如果di,就会被吃掉。 求出所有动物到达时间最短的minTime。

过程:Kicc开始干活,然后动物开始跑,minTime之后,Kicc开始休息,动物开始返回。此时,剩余时间T-minTime。 再之后呢,当动物回到起点时,Kicc开始干活,动物出发;动物到达,Kicc停止干活,休息。


#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int d[1000005],s[1000005],t[1000005];

int main()
int T, X, sum=0;
int m;
return 0;
for(int i=0;i<m;i++)
t[i] = (d[i]-1)/s[i];
int minTime = t[0];
return 0;
sum = T*X;
T -= minTime;
sum += minTime*X;
T /= 2;
sum += T*X;

return 0;