import numpy as np N, V, L = map(int, input().split()) INF = 10 ** 18 dp = np.full(V + 1, INF) dp[V] = 0 cur = 0 for _ in range(N): new_dp = np.full(V + 1, INF) x, v, w = map(int, input().split()) if v == 0: continue dist = x - cur if dist > V: print(-1) exit() new_dp[:V + 1 - dist] = dp[dist:] dp = new_dp.copy() if v <= V: new_dp[v:] = np.minimum(new_dp[v:], dp[:-v] + w) new_dp[V] = min(new_dp[V], np.min(dp[-v:]) + w) else: new_dp[V] = min(new_dp[V], np.min(dp) + w) dp = new_dp.copy() cur = x if L - cur > V: print(-1) exit() ans = np.min(dp[L - cur:]) print(ans if ans != INF else -1)