1 solutions
-
0
Pascal :
var t,tt,i,m,n,a,b:longint; sum:array[0..1000] of longint; begin readln(n,m); for i:=1 to m do begin readln(a,b); inc(sum[a],b); end; for i:=0 to 1000 do begin if sum[i]<>0 then begin inc(t,i*sum[i]); inc(tt,sum[i]); end; if tt>=n then break; end; t:=t-(tt-n)*i; writeln(t); end.
- 1
Information
- ID
- 18044
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By