I suspect that the testing data does not follow this condition in the problem description:
the intermediate and final results will fit in a 32-bit signed integer.
After I increased the size of the variables used to store intermediate and final results from int to long long, I got AC. Does there ...
Search found 2 matches
- Fri Feb 13, 2015 10:35 am
- Forum: Volume 108 (10800-10899)
- Topic: 10875 - Big Math
- Replies: 27
- Views: 9396
- Mon Sep 04, 2006 2:28 am
- Forum: Volume 110 (11000-11099)
- Topic: 11080 - Place the Guards
- Replies: 40
- Views: 18328
Dear ivan, here is the example which will prove the greedy algorithm is wrong:
If you use the greedy algorithm, the output will be 9
Code: Select all
input:
1
13 12
0 8
1 8
2 9
3 9
4 10
5 10
6 11
7 11
8 12
9 12
10 12
11 12
output:
4