
codility
zll00561
这个作者很懒,什么都没留下…
展开
-
FrogRiverOne
A small frog wants to get to the other side of a river. The frog is currently located at position 0, and wants to get to position X. Leaves fall from a tree onto the surface of the river. You are give原创 2015-04-09 14:10:15 · 603 阅读 · 0 评论 -
MaxCounters
You are given N counters, initially set to 0, and you have two possible operations on them: increase(X) − counter X is increased by 1, max counter − all counters are set to the maximum value of any c原创 2015-04-09 15:38:43 · 536 阅读 · 0 评论 -
1. PermCheck Check whether array A is a permutation.
A non-empty zero-indexed array A consisting of N integers is given. A permutation is a sequence containing each element from 1 to N once, and only once. For example, array A such that: A[0] = 4原创 2015-04-09 10:23:12 · 669 阅读 · 0 评论 -
3.1 PassingCars
A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road. Array A contains only 0s and/or 1s: 0 represents a car tr原创 2015-04-09 21:15:30 · 802 阅读 · 0 评论 -
DP-MinAbsSum
给定一个数组N个正整数,给每个数一个符号,正或者负使得所有数的的和的绝对值尽可能大。也就是使得这个 val(A, S) = |sum{ A[i]*S[i] for i = 0..N−1 }尽可能大s[i] = +1或者-1。 通过分析可以发现元素的正负不影响结果,问题转化为将数分成两堆,两堆只差最小。首先将元素全部转成正数顺便做了个count sort. 发现这个问题转化为多重背包问题。 DP原创 2015-05-24 22:45:03 · 901 阅读 · 0 评论