- Problem Statement.
- A
**main()**with the examples compiled in. - A skeleton that compiles with
**main.cpp**. -
**Problem Given in Topcoder**: November, 2013 -
**Competitors who opened the problem**: 1071 -
**Competitors who submitted a solution**: 1007 -
**Number of correct solutions**: 611 -
**Accuracy (percentage correct vs those who opened)**: 57.0% -
**Average Correct Time**: 13 minutes, 53 seconds.

Now, since the vector is sorted, you can start with the first element, and see whether you can double it until it equals the second element, or is greater than the second element. If greater, then the answer is "NO". If equal, then you can move on to the second element.

With the second element, you keep doubling it until it is equal to or greater than the third element.

And so on. Once again, the key step was sorting the input. This lets you know that each element is less than or equal to the next element, and you can keep doubling it. If you didn't sort, then you'd have to do more work to figure out which elements to double.

You should ask yourself two questions before you hit

- Will this be too slow? The answer is no, because you can double at most
30 times before you hit 10
^{9}(which roughly equals 2^{30}). - Should I be worried about integer overflow. As it turns out, no. The
maximum integer is (2
^{31}-1), which is roughly 2,000,000,000. A little larger, actually. The maximum value that you'll get to double is 999,999,999, and that doubled is less than 2,000,000,000. You're good.