// Arup Guha
// 8/8/2018
// Solution to Proposed 2018 NAQ Problem: Longest Life

import java.util.*;
import java.io.*;

public class longestlife {
	
	public static int n;
	public static pill[] list;
	public static int c;
	
	public static void main(String[] args) throws Exception {
	
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		long reg = Long.parseLong(tok.nextToken());
		n = Integer.parseInt(tok.nextToken());
		c = Integer.parseInt(tok.nextToken());
		list = new pill[n];
		
		// Read in all of the pills.
		for (int i=0; i<n; i++) {
			tok = new StringTokenizer(stdin.readLine());
			long t = Long.parseLong(tok.nextToken());
			int real = Integer.parseInt(tok.nextToken());
			int mine = Integer.parseInt(tok.nextToken());
			list[i] = new pill(t, mine, real, c);
		}
		
		// This stack will maintain all of our potential best options.
		ArrayDeque<line> options = new ArrayDeque<line>();
		ArrayDeque<pair> ranges = new ArrayDeque<pair>();
		
		// This is the option of taking no pills.
		options.offer(new line(new pt(0,0), new pt(1,1)));
		ranges.offer(new pair(0, 1e18));
		double res = reg;
		
		// Go through each pill.
		for (int i=0; i<n; i++) {
			
			// Skip it if this slope isn't the best.
			pt curBestSlope = options.peekLast().dir;
			if (list[i].slope.compareTo(curBestSlope) <= 0) continue;
			
			// Get rid of options that can't compete with this one for sure.
			while (ranges.peekFirst().e < list[i].t) {
				ranges.removeFirst();
				options.removeFirst();
			}
			
			// Get our best line using this pill.
			double myx = options.peekFirst().getX(list[i].t) + list[i].c;
			if (myx > reg) continue;
			line cur = new line(new pt(myx, list[i].t), new pt(list[i].x, list[i].y));
			
			// Update our option arraydeque.
			while (options.size() > 0) {
				
				line mybest = options.peekLast();
				double yint = cur.beat(mybest);
				
				// If I beat you before you start, you were never meant to be.
				if (yint < ranges.peekLast().s) {
					ranges.removeLast();
					options.removeLast();
					ranges.peekLast().e = 1e18;
				}
				
				// You dominate until yint, I dominate from that point on.
				else {
					ranges.peekLast().e = yint;
					ranges.addLast(new pair(yint, 1e18));
					options.addLast(cur);
					res = Math.max(res, cur.eval(reg));
					break;
				}
			} // end while true for adding this option.
		} // end for pills
		
		// Ta da!
		System.out.printf("%.9f\n",res);
	}
}

class pair {
	
	public double s;
	public double e;
	
	public pair(double mys, double mye) {
		s = mys;
		e = mye;
	}
}

class pill implements Comparable<pill> {
	
	public long t;
	public pt slope;
	public long x;
	public long y;
	public long c;
	
	public pill(long myt, int myx, int myy, int myc) {
		t = myt;
		x = myx;
		y = myy;
		c = myc;
		slope = new pt(x, y);
	}
	
	public int compareTo(pill other) {
		if (t < other.t) return -1;
		if (t > other.t) return 1;
		return 0;
	}
}

class pt implements Comparable<pt> {

	public double x;
	public double y;
	
	public pt(double myx, double myy) {
		x = myx;
		y = myy;
	}
	
	// A slope comparison.
	public int compareTo(pt other) {
		if (y*other.x < x*other.y-1e-2) return -1;
		if (y*other.x-1e-2 > x*other.y) return 1;
		return 0;
	}
	
	public String toString() {
		return "["+x+","+y+"] ";
	}
}

class line {
	
	public pt start;
	public pt dir;
	
	public line(pt s, pt d) {
		start = s;
		dir = d;
	}
	
	public String toString() {
		return start+"-> "+dir;
	}
	
	// Returns the corresponding y for this xVal.
	public double eval(double xVal) {
		return start.y + (xVal-start.x)*dir.y/dir.x; 
	}
	
	public double getX(double yVal) {
		return start.x + (yVal-start.y)*dir.x/dir.y;
	}
	
	// Returns the y value where this line beats other.
	public double beat(line other) {
		
		// Should never be called in this case but I am being cautious.
		if (dir.compareTo(other.dir) <= 0) return -1;;
		
		// Solve the system of equations.
		double den = det(dir.x,-other.dir.x, dir.y, - other.dir.y);
		double num = det(other.start.x-start.x, -other.dir.x, other.start.y-start.y, -other.dir.y);
		double lambda = num/den;
		return start.y + lambda*dir.y;
	}
	
	public static double det(double a, double b, double c, double d) {
		return a*d - b*c;
	}
}