洛谷水数据,水范围,给了我们很多可能。暴力贪心,每次选单价最小的,直到完成任务var t,tt,i,m,n,a,b:longint; sum:array[0..10000] of int64;begin readln(n,m); for i:=1 to m do begin readln(a,b); sum[a]:=sum[a]+b; end; for i:=0 to 10000 do begin if sum[i]<>0 then begin t:=t+i*sum[i];tt:=tt+sum[i];end; if tt>=n then break; end; t:=t-(tt-n)*i; writeln(t);end.