mod = 1000000007 eps = 10 ** -9 inf = 10 ** 15 def main(): import sys input = sys.stdin.buffer.readline N, Vmax, L = map(int, input().split()) X = [0] * (N + 1) V = [0] * (N + 1) W = [0] * (N + 1) for i in range(1, N + 1): x, v, w = map(int, input().split()) X[i] = x V[i] = v W[i] = w X.append(L) V.append(0) W.append(0) dp = [[inf] * (Vmax + 1) for _ in range(N + 2)] dp[0][Vmax] = 0 for i in range(1, N + 2): x, v, w = X[i], V[i], W[i] d = x - X[i-1] for j in range(Vmax+1): if j - d >= 0: dp[i][j-d] = dp[i-1][j] dp[i][min(Vmax, j-d + v)] = min(dp[i][min(Vmax, j-d+v)], dp[i-1][j] + w) ans = min(dp[-1]) if ans == inf: print(-1) else: print(ans) if __name__ == '__main__': main()