Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var u,n,i,y,j,q,w,k,x,o,p,min,num:longint;
- speed:extended;
- s:string;
- a:array[0..100] of string;
- b,c:array[0..100] of longint;
- begin
- assign(input,'input.txt');
- reset(input);
- assign(output,'output.txt');
- rewrite(output);
- readln(n);
- q:=0;
- w:=0;
- for i:=1 to n do
- begin
- k:=0;
- u:=0;
- q:=0;
- w:=0;
- y:=0;
- x:=0;
- readln(s);
- for j:=1 to length(s) do
- begin
- if s[j]='"' then inc(u)
- else
- if u=1 then a[i]:=a[i]+s[j]
- else
- if (s[j]=' ') and (u=2) then inc(k)
- else
- if k=1 then
- begin
- inc(q);
- if q<3 then
- begin
- val(s[j],o,p);
- b[i]:=b[i]*10+o;
- end
- else
- if q=3 then b[i]:=b[i]*60
- else
- if q>3 then
- begin
- val(s[j],o,p);
- x:=x*10+o;
- if q=5 then
- b[i]:=b[i]+x;
- end;
- end
- else
- if k=2 then
- begin
- inc(w);
- if w<3 then
- begin
- val(s[j],o,p);
- c[i]:=c[i]*10+o;
- end
- else
- if w=3 then c[i]:=c[i]*60
- else
- if w>3 then
- begin
- val(s[j],o,p);
- y:=y*10+o;
- if w=5 then c[i]:=c[i]+y;
- end;
- end;
- end;
- end;
- min:=maxlongint;
- for i:=1 to n do
- if (c[i]<=b[i]) then
- begin
- x:=c[i]+1440-b[i];
- b[i]:=0;
- c[i]:=x;
- end;
- for i:=1 to n do
- if (abs(c[i]-b[i])<min) and (abs(c[i]-b[i])>0) and (abs(c[i]-b[i])<=1440) then
- begin
- min:=abs(c[i]-b[i]);
- num:=i;
- end;
- speed:=650/(min/60);
- writeln('The fastest train is "',a[num],'".');
- writeln('It''s speed is ',speed:0:0,' km/h, approximately.');
- close(input);
- close(output);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement