ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1031. Железнодорожные билеты

Показать все сообщения Спрятать все сообщения

Why am i getting wrong answer? here is my scource Costel::icerapper@k.ro 27 фев 2002 18:04
program timus_p1031;
const
  maxn=10000;
  maxk=1000000000;
type
  tart=record
             cost:longint;
             poz:longint;
       end;
  ta=array[1..maxn]of tart;
var
  l1,l2,l3,c1,c2,c3:longint;
  a:ta;
  n:longint;
  x,y:longint;

procedure init_data;
begin
  fillchar(a,sizeof(a),0);
end;

procedure Swap(var x,y:longint);
var
  z:longint;
begin
  z:=x;
  x:=y;
  y:=z;
end;

procedure read_data;
var
  i:longint;
begin
  readln(l1,l2,l3,c1,c2,c3);
  readln(n);
  readln(x,y);
  if x>y then
    Swap(x,y);
  for i:=2 to x-1 do
    readln;
  for i:=x to y do
    readln(a[i].poz);
end;

function TicketCost(st2,st1:longint):longint;
begin
  TicketCost:=0;
  if st2-st1>l3 then
    exit;
  TicketCost:=c3;
  if st2-st1>l2 then
    exit;
  TicketCost:=c2;
  if st2-st1>l1 then
    exit;
  TicketCost:=c1;
end;

procedure TakeChiefestTicket(station:longint);
var
  i:longint;
  d:longint;
begin
  a[station].cost:=maxk+1;
  for i:=station-1 downto x do
  begin
    d:=TicketCost(a[station].poz,a[i].poz);
    if d=0 then
      break;
    if (d+a[i].cost)<a[station].cost then
      a[station].cost:=d+a[i].cost;
  end;
  if a[station].cost>maxk then
    a[station].cost:=maxk+1;
end;

procedure art_solve;
var
  i:longint;
begin
  for i:=x+1 to y do
    TakeChiefestTicket(i);
end;

procedure write_sol;
begin
  writeln(a[y].cost);
end;

begin
  init_data;
  read_data;
  art_solve;
  write_sol;
end.