n,v,l = map(int,input().split()) xvw = [[int(i) for i in input().split()] for j in range(n)] dp = [10**15]*(l+1) dp[v] = 0 pos = 0 for i in range(n): x,vi,wi = xvw[i] dis = x-pos for j in range(l+1): if dis > j: dp[j] = 10**15 else: dp[j-dis] = dp[j] #print(dis) for j in range(l+1): dp[min(v,j+vi)] = min(dp[j]+wi,dp[min(v,j+vi)]) pos = x #print(dp,i) if pos != l: dis = l-pos ans = 10**15 for j in range(l+1): if dis <= j: ans = min(ans,dp[j]) else: ans = min(dp) if ans >= 10**15: print(-1) else: print(ans)