Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. var u,n,i,y,j,q,w,k,x,o,p,min,num:longint;
  2. speed:extended;
  3. s:string;
  4. a:array[0..100] of string;
  5. b,c:array[0..100] of longint;
  6. begin
  7. assign(input,'input.txt');
  8. reset(input);
  9. assign(output,'output.txt');
  10. rewrite(output);
  11. readln(n);
  12. q:=0;
  13. w:=0;
  14. for i:=1 to n do
  15. begin
  16. k:=0;
  17. u:=0;
  18. q:=0;
  19. w:=0;
  20. y:=0;
  21. x:=0;
  22. readln(s);
  23. for j:=1 to length(s) do
  24. begin
  25. if s[j]='"' then inc(u)
  26. else
  27. if u=1 then a[i]:=a[i]+s[j]
  28. else
  29. if (s[j]=' ') and (u=2) then inc(k)
  30. else
  31. if k=1 then
  32. begin
  33. inc(q);
  34. if q<3 then
  35. begin
  36. val(s[j],o,p);
  37. b[i]:=b[i]*10+o;
  38. end
  39. else
  40. if q=3 then b[i]:=b[i]*60
  41. else
  42. if q>3 then
  43. begin
  44. val(s[j],o,p);
  45. x:=x*10+o;
  46. if q=5 then
  47. b[i]:=b[i]+x;
  48. end;
  49. end
  50. else
  51. if k=2 then
  52. begin
  53. inc(w);
  54. if w<3 then
  55. begin
  56. val(s[j],o,p);
  57. c[i]:=c[i]*10+o;
  58. end
  59. else
  60. if w=3 then c[i]:=c[i]*60
  61. else
  62. if w>3 then
  63. begin
  64. val(s[j],o,p);
  65. y:=y*10+o;
  66. if w=5 then c[i]:=c[i]+y;
  67. end;
  68. end;
  69. end;
  70. end;
  71. min:=maxlongint;
  72. for i:=1 to n do
  73. if (c[i]<=b[i]) then
  74. begin
  75. x:=c[i]+1440-b[i];
  76. b[i]:=0;
  77. c[i]:=x;
  78. end;
  79. for i:=1 to n do
  80. if (abs(c[i]-b[i])<min) and (abs(c[i]-b[i])>0) and (abs(c[i]-b[i])<=1440) then
  81. begin
  82. min:=abs(c[i]-b[i]);
  83. num:=i;
  84. end;
  85. speed:=650/(min/60);
  86. writeln('The fastest train is "',a[num],'".');
  87. writeln('It''s speed is ',speed:0:0,' km/h, approximately.');
  88. close(input);
  89. close(output);
  90. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement