Nifty ends marginally higher at 24,252, Sensex flat at 77,540