The work is the dot product, not just a simple multiplication. If the same magnitude of force is used in both the cases, but with directions different (one upward and one in direction of ramp), the work will be different. This difference will manifest as the greater-work-done case having more final acceleration of the object, assuming initial velocity is same. Work-energy theorem.
For the work done to be same in both cases, you will find that the force required in one case (ramp) will be higher, as only the vertical component of the force will contribute to the work done (hence the dot product) against gravity. The rest of the force is used to maintain the trajectory in the ramp (constraint, due to the normal force that the ramp provides).
I have assumed there is no friction, as implied from your question. And this analysis should ideally be done without assuming any acceleration, i.e., the force required to exactly counter the gravitational force. That will give the same results with almost similar arguments.