#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, V, L; cin >> n >> V >> L; vector x(n + 2), v(n + 1), w(n + 1); for(int i = 1; i <= n; i++){ cin >> x[i] >> v[i] >> w[i]; } x[n + 1] = L; vector> dp(n + 2, vector(V + 1, 1ll << 60)); dp[0][V] = 0; for(int i = 0; i <= n; i++){ int d = x[i + 1] - x[i]; for(int j = 0; j <= V; j++){ int nj = min(V, j + v[i]); if(nj >= d) dp[i + 1][nj - d] = min(dp[i + 1][nj - d], dp[i][j] + w[i]); if(j >= d) dp[i + 1][j - d] = min(dp[i + 1][j - d], dp[i][j]); } } ll ans = *min_element(dp.back().begin(), dp.back().end()); cout << (ans >> 60 ? -1 : ans) << '\n'; }