def MinAdjustmentCost(self, A, target):
        """
        state dp

        f[i][j] = min(f[i-1][k] + |a[i]-j|, for k j-l to j+l)

        comments: similar to Vertibi algorithm (Hidden Markov Model)

        :param A: An integer array.
        :param target: An integer.
        """
        S = 100
        n = len(A)
        f = [[1<<31 for _ in xrange(S+1)] for _ in xrange(n+1)]

        for j in xrange(S+1):
            f[0][j] = 0

        for i in xrange(1, n+1):
            for j in xrange(1, S+1):
                for k in xrange(max(1, target-j), min(S, j+target)+1):
                    f[i][j] = min(f[i][j], f[i-1][k]+abs(A[i-1]-j))

        mini = 1<<31
        for j in xrange(1, S+1):
            mini = min(mini, f[n][j])

        return mini
dataset/ETHPy150Open algorhythms/LintCode/Minimum Adjustment Cost.py/Solution.MinAdjustmentCost/swapped operands of `-`