#include using namespace std; int main() { int N, V, L; cin >> N >> V >> L; struct { int x; int v; int w; } a[N+2]; for (int i = 1; i <= N; i++) { cin >> a[i].x >> a[i].v >> a[i].w; } a[0].x = 0; a[N+1].x = L; vector> dp(N+2, vector(V+1, 1 << 30)); dp[0][V] = 0; for (int i = 0; i < N+2; i++) { for (int j = 0; j <= V; j++) { if (dp[i][j] != 1 << 30 && a[i+1].x - a[i].x <= j) { dp[i+1][min(V, j-a[i+1].x+a[i].x+a[i+1].v)] = min(dp[i+1][min(V, j-a[i+1].x+a[i].x+a[i+1].v)], dp[i][j] + a[i+1].w); dp[i+1][j-a[i+1].x+a[i].x] = min(dp[i+1][j-a[i+1].x+a[i].x], dp[i][j]); } } } int ans = 1 << 30; for (int i = 0; i <= V; i++) ans = min(ans, dp[N+1][i]); if (ans == 1 << 30) ans = -1; cout << ans << endl; }