#include #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector VI; typedef pair P; typedef tuple t3; typedef tuple t4; typedef tuple t5; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,b,n) for(ll a = b;a < n;a++) using namespace std; static const ll INF = 1e15; const ll mod = 1000000007; template void chmin(T & ref, const T value) { if (ref > value) ref = value; } int main() { ll n, v, l; cin >> n >> v >> l; vector xs(n+1, 0), vs(n+1,0), ws(n+1,0); rep(i, n) { cin >> xs[i+1] >> vs[i+1] >> ws[i+1]; } vector> dp(n + 1, vector(v + 1, INF)); dp[0][v] = 0; rep(i, n) { ll d = xs[i + 1] - xs[i]; rep(j, v + 1) { if (j >= d) { chmin(dp[i + 1][j - d], dp[i][j]); auto nv = min(v, j - d + vs[i + 1]); chmin(dp[i + 1][nv], dp[i][j] + ws[i + 1]); } } } ll low = INF; for (int j = l - xs[n]; j < v + 1;j++) { chmin(low, dp[n][j]); } if (low == INF) { cout << -1 << endl; } else { cout << low << endl; } return 0; }