n, V_, l = map(int, input().split()) X = [-1] * n V = [-1] * n W = [-1] * n for i in range(n): X[i], V[i], W[i] = map(int, input().split()) bef = 0 inf = 1 << 60 dp = [inf] * (V_ + 1) dp[V_] = 0 for x, v, w in zip(X, V, W): d = x - bef bef = x ndp = [inf] * (V_ + 1) for i in range(d, V_ + 1): ndp[i - d] = dp[i] for i in range(V_, -1, -1): j = min(V_, i + v) ndp[j] = min(ndp[j], ndp[i] + w) dp = ndp d = l - bef try: ans = min(dp[d:]) if ans == inf: ans = -1 print(ans) except: print(-1)