Mai intai trebuie sa te autentifici.
Cod sursa(job #636387)
| Utilizator | Data | 19 noiembrie 2011 19:33:37 | |
|---|---|---|---|
| Problema | Zombie | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | .com 2011 | Marime | 1.32 kb |
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,'zombie2.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.
