import sys readline = sys.stdin.readline N, V, L = map(int, readline().split()) xvw = [tuple(map(int, readline().split())) for _ in range(N)] INF = 1<<60 dp = [INF]*(V+1) dp[V] = 0 pre = 0 for x, v, w in xvw: dist = x-pre dp2 = dp[dist:] + [INF]*(V+1-min(0, V+1-dist)) for vi in range(V+1-dist): vidx = min(V, vi+v) dp2[vidx] = min(dp2[vidx], dp[vi+dist]+w) dp = dp2[:] pre = x ans = min(dp[L-pre:]) if ans == INF: ans = -1 print(ans)