There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[...
                            
                            
                                分类:
其他好文   时间:
2015-07-26 17:13:24   
                                阅读次数:
112
                             
                         
                    
                        
                            
                            
                                空间站是有一些球状的房间组成的,现在有一些房间但是没有相互连接,你需要设计一些走廊使他们都相通,当然,有些房间可能会有重合(很神奇的样子,重合距离是0),你需要设计出来最短的走廊使所有的点都连接。分析:因为给的都是点的坐标,所以构图的时候会有一些麻烦,不过也仅此而已。。。**************...
                            
                            
                                分类:
其他好文   时间:
2015-07-24 20:30:54   
                                阅读次数:
101
                             
                         
                    
                        
                            
                            
                                题目描述:
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Dif...
                            
                            
                                分类:
编程语言   时间:
2015-07-24 16:13:03   
                                阅读次数:
145
                             
                         
                    
                        
                            
                            
                                There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its nex...
                            
                            
                                分类:
其他好文   时间:
2015-07-22 21:01:26   
                                阅读次数:
217
                             
                         
                    
                        
                            
                            
                                题意:
N个点,再点上建M个消防站。
问消防站到每个点的最大距离的最小是多少。
思路:
DLX直接二分判断TLE了。
这时候一个很巧妙的思路
我们求的距离一定是两个点之间的距离
因此我们把距离都求一遍排序一下。
然后用下标二分  这样就AC了。
代码:
#include"stdio.h"
#include"algorithm"
#include"string.h"
#inclu...
                            
                            
                                分类:
其他好文   时间:
2015-07-21 12:58:45   
                                阅读次数:
119
                             
                         
                    
                        
                            
                            
                                题目描述:在一个环形路上有n个加油站,每个加油站i 的油量为gas[i],你有一个无限大的油箱,从一个加油站i到下一个加油站i+1消耗油量cost[i],你从一个加油站开始,并且油箱没有油,如果能够绕环形路一圈,返回开始加油站的索引,否则返回-1.分析:要保证能够行走一圈,则所有站的油量之和一定要大...
                            
                            
                                分类:
其他好文   时间:
2015-07-21 01:20:15   
                                阅读次数:
99
                             
                         
                    
                        
                            
                            
                                题目 134 Gas Station这道题有一个需要利用的条件即是如果存在这样一个station则答案唯一。class Solution: # @param {integer[]} gas # @param {integer[]} cost # @return {integer} ...
                            
                            
                                分类:
其他好文   时间:
2015-07-13 15:43:58   
                                阅读次数:
93