""" dpだろうね N,Vが小さいので、これでdpか? dp[i番目のgsに来た時][燃料残量] = 最小のコスト """ N,V,L = map(int,input().split()) dp = [[float("inf")] * (V+1) for i in range(N+2)] dp[0][V] = 0 lastx = 0 for i in range(N+1): if i == N: x = L v = 0 w = 0 else: x,v,w = map(int,input().split()) for j in range(V-(x-lastx)+1): dp[i+1][j] = dp[i][j+x-lastx] for j in range(V,-1,-1): dp[i+1][min(V,j+v)] = min(dp[i+1][min(V,j+v)] , dp[i+1][j] + w) lastx = x ans = min(dp[-1]) if ans == float("inf"): print (-1) else: print (ans)