import sys input = sys.stdin.readline inf = 10 ** 18 N, V, L = map(int, input().split()) station = [tuple(map(int, input().split())) for _ in range(N)] station.append((L, 0, 0)) dp = [inf] * (V + 1) dp[V] = 0 pos = 0 for x, v, w in station: dist = x - pos newDP = [inf] * (V + 1) for i in range(dist, V + 1): # 補給しない gas = i - dist newDP[gas] = min(newDP[gas], dp[i]) # 補給する gas = min(V, i - dist + v) newDP[gas] = min(newDP[gas], dp[i] + w) dp = newDP pos = x ans = min(dp) if ans >= inf: print(-1) else: print(ans)