import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int v = sc.nextInt(); int l = sc.nextInt(); GS[] stations = new GS[n + 2]; for (int i = 1; i <= n; i++) { stations[i] = new GS(sc.nextInt(), sc.nextInt(), sc.nextInt()); } stations[0] = new GS(0, 0, 0); stations[n + 1] = new GS(l, 0, 0); ArrayList> dp = new ArrayList<>(); for (int i = 0; i <= n + 1; i++) { dp.add(new HashMap<>()); } dp.get(0).put(v, 0L); for (int i = 1; i <= n + 1; i++) { int length = stations[i].point - stations[i - 1].point; HashMap map = dp.get(i); for (Map.Entry entry : dp.get(i - 1).entrySet()) { int gas = entry.getKey() - length; if (gas < 0) { continue; } if (map.containsKey(gas)) { if (map.get(gas) > entry.getValue()) { map.put(gas, entry.getValue()); } } else { map.put(gas, entry.getValue()); } long cost = entry.getValue() + stations[i].cost; gas = Math.min(v, gas + stations[i].gas); if (map.containsKey(gas)) { if (map.get(gas) > cost) { map.put(gas, cost); } } else { map.put(gas, cost); } } } if (dp.get(n + 1).size() == 0) { System.out.println(-1); return; } long min = Long.MAX_VALUE; for (long x : dp.get(n + 1).values()) { min = Math.min(x, min); } System.out.println(min); } static class GS { int point; int gas; int cost; public GS(int point, int gas, int cost) { this.point = point; this.gas = gas; this.cost = cost; } } }