Cod sursa(job #635730)
Utilizator | Data | 19 noiembrie 2011 14:33:34 | |
---|---|---|---|
Problema | Zombie | Scor | 0 |
Compilator | fpc | Status | done |
Runda | .com 2011 | Marime | 1.97 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;
for i:=1 to n-1 do begin
read(fi,a[i]);
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); }
read(fi,s); l:=length(s); p:=1;
for i:=1 to n do a[i]:=citire;
close(fo);
end.