N, VV, L = map(int, input().split()) X, V, W = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1) for i in range(N): X[i + 1], V[i + 1], W[i + 1] = map(int, input().split()) inf = 10 ** 18 pre = [inf] * (VV + 1) pre[VV] = 0 for i in range(N): dp = [inf] * (VV + 1) x = X[i + 1] - X[i] for j in range(VV + 1): if j - x >= 0: dp[j - x] = min(dp[j - x], pre[j]) dp[min(VV, j - x + V[i + 1])] = min(dp[min(VV, j - x + V[i + 1])], pre[j] + W[i + 1]) dp, pre = pre, dp ans = inf for i in range(VV + 1): if i - (L - X[-1]) >= 0: ans = min(ans, pre[i]) print(ans) if ans < inf else print(-1)