算法过程如何进行优化的问题,怎么使用C语言的编写来实现的

Problem Description
ACboy is playing a new stone game. There's a rectangular grid board, and some stones placed at the initial location Bi(Xi, Yi) and the targets are at the location Si(Pj, Qj), the time that moving between them is Di,j = |Xi - Pj| + |Yi - Qj| + 1 minutes. And at different places may have different stones, and different target places have different capacity. In the following picture, B1,2,3 stands for the initial places, S1,2,3,4 stands for the target places. In detail, B1(5) means there are 5 stones at this location, S2(4) means you can move at most 4 stones to this target location.

The one who moves the stones from the initial places to the target places using less time will win. So ACboy now telling you his play plan, and you should tell hime whether his plan is the best, or he can do it better.

Input
The input file consists of The game board description and the play plan description. The first line of the input file consists of two numbers N and M separated by a space. N (1 <= N <= 100) is a number of initial places(numbered from 1 to N). M (1 <= M <= 100) is a number of target places(numbered from 1 to M).

The following N lines describe initial places. Each line contains there integer numbers Xi, Yi, and Bi separated by spaces, where Xi, Yi (-1000 <= Xi, Yi <= 1000) are the coordinates of initial places, and Bi (1 <= Bi <= 1000) is the number of stones at this location.

The description of initial places is followed by M lines that describe target places. Each line contains three integer numbers Pj, Qj, and Cj separated by spaces, where Pi, Qi (-1000 <= Pj, Qj <= 1000) are the coordinates of the target places, and Cj (1 <= Cj <= 1000) is the capacity of this place.

The description of the play plan follows on the next N lines. The play plan of ith initial place consists of M integer numbers Ei,j separated by spaces. Ei,j (0 <= Ei, j <= 1000) is a number of stones that shall move from the ith initial place to the jth target place.

The plan in the input file is guaranteed to be valid. Namely, B1+B2+....+Bn <= S1+S2+....+Sn.

Process to the end of file.

Output
If ACboy's plan is the best, print "good", otherwise, print"I can do it better".

Sample Input
2 1
0 0 5
1 1 5
2 2 5
5
0

Sample Output
I can do it better

Hint: in the case, ACboy moves the 5 stones from B1 at (0,0) to S1 at (2,2), and it costs him 5*5 = 25 minutes,
but if he move the 5 stones from B2 at (1,1) to S1 at (2,2), it will only takes him 3*5 = 15 minutes, so his plan is not the best.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

2
一个c语言的算法循环问题
1
机器人的位置移动的问题,用C语言编写算法解决,谢谢
1
复杂度的一个控制的算法的问题,怎么采用的C语言的程序的编写的过程来实现的?
0
给一颗二叉树标记颜色的一个算法,怎么使用C语言的程序编写的过程去解决此问题?
0
二叉树构造最小堆的问题算法,怎么使用C语言的代码编写的过程完成这个数据结构的办法?
0
要求使用算法对密码解密的一个问题,怎么利用C语言的程序编写的过程形式去实现程序的?
0
字符串快速查找算法的问题,怎么使用 C 语言的程序的编写的办法怎么来查找的?
0
区间线段的搜索问题的综合运用,怎么使用C语言的程序编写的程序的格式来实现算法的解答
0
输出可能的领先的选手数量的算法,怎么使用C语言的程序编写的过程的方式去实现的程序编写
0
位置是否相邻的计算的问题,怎么使用C语言的程序代码编写的过程有效实现这个算法问题的
0
路径寻找算法的优化问题,怎么使用C语言的程序编写的代码思想的办法,有效地实现
0
关键字匹配搜索的算法问题,怎么使用C语言的程序的代码编写的过程思想方法来实现比较好
0
计算教室里的座位的位置的一个算法问题,是如何采用C语言的程序编写设计的代码过程的步骤来完成的
0
汽车的调度的一个算法问题的求解的过程,怎么使用C语言的程序的编写的方式来实现的?
0
一个统筹的算法的计算的问题,怎么使用C语言的程序的代码编写过程的实现怎么来做
0
计算俱乐部的投票的算法问题,是如何采用C语言的程序编写的技术的过程的形式来实现程序的设计的
0
构造队列的一个算法的问题,怎么采用C语言的程序的设计的编写的过程的技术实现的
0
按格式解析时间段的一个算法的问题怎么用C语言的程序的编写的设计的过程来解决的
0
RGB三原色的混合的计算问题,怎么使用C语言的程序的代码的编写的过程有效实现这个算法
0
最小费用建模的一个算法问题,要求使用的C语言的程序的编写怎么来做的