问题可以在这里找到:
http://code.google.com/codejam/contest/dashboard?c=975485#s=p3CodeJam 2011:Gorosort的解决方案?
我不明白为什么
answer = no. of elements that are not in the correct position
例如,假设我有排序数组:
3 1 2
所以我这样想:
Array: 3 1 2 1st: freeze 2 to sort 1 (take 2 hits) Array: 1 3 2 2nd: freeze 1 to sort 2 and 3 (take another 2 hits)
因此,我的答案是4,但正确的答案是3.
任何人都可以澄清我这个问题吗?
你应该请阅读证明:http://code.google.com/codejam/contest/dashboard?c=975485#s=a&a=3 – 2011-05-08 16:27:57
他们还写道,策略只保留已排序的元素。在你的数组中,没有元素位于正确的位置,所以你不会按住任何元素。你得到4是因为你使用了错误的策略。 *为什么*这个策略的作用是证明(我不能向你解释,我必须花更多的时间与我自己;)) – 2011-05-08 16:39:22
感谢您的帮助。但不,我不这么认为。根据问题页面底部的说明部分:http://code.google.com/codejam/contest/dashboard?c=975485#s=p3&a=3。可以保留不正确位置的元素。 – Tianissimo 2011-05-08 16:59:32