#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair P; typedef pair PL; constexpr ll INF = (1LL << 60); typedef tuple TP; int main() { int n, V, L; cin >> n >> V >> L; vector g; for (int i = 0; i < n; i++) { int x, v, w; cin >> x >> v >> w; g.emplace_back(make_tuple(x, v, w)); } g.emplace_back(make_tuple(L, 0, 0)); vector dp(V + 1, INF); dp[V] = 0; int prev = 0; for (int i = 0; i < n + 1; i++) { int x, v, w; tie(x, v, w) = g[i]; int dif = x - prev; for (int j = 0; j <= V; j++) { if (j - dif >= 0) dp[j - dif] = dp[j]; dp[j] = INF; } for (int j = V; j >= 0; j--) { int to = min(V, j + v); dp[to] = min(dp[to], dp[j] + w); } prev = x; } ll res = INF; for (int i = V; i >= 0; i--) { res = min(res, dp[i]); } cout << (res == INF ? -1 : res) << endl; return 0; }