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

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

cai niao where is the error? [1] // Задача 1031. Железнодорожные билеты 3 ноя 2001 10:16
I don't think there is any error, but I get a "wrong
answer".

var
    cost: array[1..10000] of longint;
    len: array[1..10000] of longint;
    l1,l2,l3,c1,c2,c3: longint;
    i,j,start,over,n: integer;
begin
    readln(l1,l2,l3,c1,c2,c3);
    readln(n);
    readln(start,over);
    for i:=2 to n do
        readln(len[i]);
    for i:=2 to n do
        cost[i]:=1000000000;
    len[1]:=0;
    cost[start]:=0;
    for i:=start to over-1 do
    begin
        j:=i+1;
        while (len[j]-len[i]<=l3) and (j<=over) do
        begin
            if len[j]-len[i]<=l1 then
            begin
                if cost[i]+c1<cost[j]
                then cost[j]:=cost[i]+c1
            end
            else if len[j]-len[i]<=l2 then
                begin
                    if cost[i]+c2<cost[j]
                    then cost[j]:=cost[i]+c2;
                end
                else if cost[i]+c3<cost[j]
                    then cost[j]:=cost[i]+c3;
            j:=j+1;
        end;
    end;
    writeln(cost[over]);
    read(i);
end.
Andras Biczo Re: where is the error? // Задача 1031. Железнодорожные билеты 3 ноя 2001 13:57
I think your error is that the starting stations number can
be greater than the destintations number. In this case you
just have to swap them.