http://codility.com/demo/take-sample-test/beta2010/ 这题以前做的时候是先排序再二分,现在觉得没有必要.首先圆可以看成线段,把线段的进入作为一个事件,出去作为一个事件.注意根据题意,同样的点,进入要在出去之前.那么O(n)扫一遍就可以得到结果.注意的是A[i]+i可能会超出int. // you can also use includes, for example: #include <algorithm> int solution(const…