Cod sursa(job #638496)
Utilizator | Data | 20 noiembrie 2011 21:54:02 | |
---|---|---|---|
Problema | Zombie | Scor | 100 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 2 kb |
Program zombie;
var n,k,i,j,cap,l,p,aux:longint;
sum,d:int64;
a:array [1..1000000] of longint;
b1:array [1..1 shl 17] of char;
s:string;
fi,fo:text;
function citire:longint;
var aux:longint;
begin
aux:=0;
while (s[p]>='0') and (s[p]<='9') and (p<=l) do begin
aux:=aux*10+ord(s[p])-48;
if p=l then begin
read(fi, s);
p:=0;
l:=length(s);
end;
inc(p);
end;
while ((s[p]<'0') or (s[p]>'9')) and (s<>'') do begin
inc(p);
if p>l then begin
read(fi, s);
p:=1;
l:=length(s);
end;
end;
citire:=aux;
end;
begin
assign(fi,'zombie.in');
assign(fo,'zombie.out');
settextbuf(fi,b1);
reset(fi); rewrite(fo);
readln(fi,d,n,k);
read(fi,cap); j:=1;
read(fi,s); l:=length(s); p:=1;
for i:=1 to n-1 do begin
a[i]:=citire;
if (a[i]-cap>=d) or (i=n-1) then begin
if j>k then sum:=sum+k
else sum:=sum+j;
cap:=a[i];
j:=1;
end
else inc(j);
end;
write(fo,sum);
close(fo);
end.