Dimarco finished off a fine team move to open the scoring after 10 minutes and Dzeko made it 2-0 with a curled finish into the bottom corner.
Martinez added a third with 13 minutes left after a neat turn inside the area to continue Milan’s poor start to the second half of the season with this a fourth match without a victory.
Edinson Cavani continued to roll back the years for Valencia with a brace in their 4-0 victory at Sporting Gijon in the Copa del Rey.
Further goals by Justin Kluivert and Samuel Lino sent last season’s runners-up through to the quarter-final stage.
Oscar De Marcos scored the only goal to help Athletic Bilbao down Espanyol at San Mames.
Elsewhere, Alvaro Morata and Marcos Llorente netted in the second half to earn Atletico Madrid a 2-0 success at Levante in the last-16.
Extra-time and penalties were required before Osasuna could beat Real Betis.
William Carvalho broke the deadlock for Betis in the 62nd minute but David Garcia netted in stoppage time for the visitors before Youssouf Sabaly and Ruben Garcia traded goals in the additional 30-minute period.
It meant spot-kicks were required and Sergio Canales and Guido Rodriguez failed to score from 12 yards in a 4-2 loss for Betis on penalties.