- 可怜的Oliver
- 2018-07-11 21:02:17 @
type
qw=array[1..200] of integer;
var
n,k,i,j,q,w:integer;
a,b:qw;
begin
read(n,k);
for i:=1 to k do
begin
read(a[i]);
readln(b[i]);
end;
i:=1;q:=n;
repeat
for j:=1 to k do
if (i=a[j])and(b[j] > w) then w:=b[j];
if w<>0 then
begin
i:=i+w;
q:=q-w;
end
else i:=i+1;
w:=0;
until i >= n;
writeln(q);
end.
0 条评论
目前还没有评论...