Dundee toiled in the first half at Balmoor last night but Madianga produced a burst of pace and an emphatic finish inside four minutes of the second period and Mendy netted with the last kick of the match.
Neil McCann’s men never looked like losing their lead as they moved on to six points in second place in Group D.
Leaders Dunfermline Athletic remain three points clear ahead of their home game against Stirling but Dundee would stand a good chance of qualifying as one of the best runners-up at least if they beat Brechin at home on Saturday afternoon.
Both teams threatened from corners in the early stages and Dundee were finding it difficult to break down the organised League Two side, who created the better openings as the first half progressed.
Ross Kavanagh had the best chance when the ball broke to him 14 yards out after a long throw but Dundee goalkeeper Elliot Parish clutched the strike above his head.
The visitors immediately stepped up the pace after the restart. Madianga arrived at speed inside the box to latch on to Paul McGowan’s lay-off and drive home.
The French midfielder and fellow summer signing Jean Mendy both produced wild efforts from decent positions as the visitors remained on top.
Dundee remained comfortable and Mendy and substitute Craig Wighton were denied in the latter stages by decent stops from Greg Fleming, before Mendy slotted home in stoppage time.