Pagini recente » Cod sursa (job #1346702) | Cod sursa (job #2332433) | Cod sursa (job #2238254) | Cod sursa (job #465080) | Cod sursa (job #636396)
Cod sursa(job #636396)
Program zombie;
var t:array[1..1000005]of longint;
s:string;
p,i,cost,j,l,d,n,k:longint;
f,g:text;
Function citire:longint;
var aux:longint;
begin
aux:=0;
while(p<=l) and (s[p]>='0') and (s[p]<='9')do begin
aux:=aux*10+(ord(s[p])-48);
if(p=l)then begin
read(f,s);
l:=length(s);
p:=0;
end;
inc(p);
end;
while (p<=l) and ((s[p]<'0') or (s[p]>'9')) do begin
inc(p);
if(p>l)then begin
read(f,s);
l:=length(s);
p:=1;
end;
end;
citire:=aux;
end;
Begin
assign(f,'zombie.in'); reset(f); readln(f,d,n,k);
read(f,s); p:=1; l:=length(s); cost:=0;
for i:=1 to n do t[i]:=citire;
i:=1;
while(i<n) do begin
j:=i+1;
while(t[j]-t[i]<d) and (j<=n)do inc(j);
if(k<j-i)then cost:=cost+k else cost:=cost+j-i;
i:=j;
end;
assign(g,'zombie.out'); rewrite(g); write(g,cost); close(g);
end.