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

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

why WA #8??? help me
Послано mcdoing_ron 12 сен 2010 14:55
I already change start and finish points
but still WA #8……
this is my coad
#include<iostream>
using namespace std;
const int maxn=10005;
long long f[maxn][maxn];
int cost[4];
int d[4];
int a[maxn];
int main()
{
            freopen("in.txt","r",stdin);
            for(int i=1;i<=3;i++)
                        cin>>d[i];
            for(int i=1;i<=3;i++)
                        cin>>cost[i];
            int n;
            cin>>n;
            for(int i=1;i<=n;i++)
                        for(int j=1;j<=n;j++)
                                    f[i][j]=INT_MAX;
            int s,e;
            cin>>s>>e;
            for(int i=2;i<=n;i++)
            {
                        cin>>a[i];
                        int temp=a[i]-a[i-1];
                        if(temp>d[2]) temp=cost[3];
                        else if(temp>d[1]) temp=cost[2];
                        else temp=cost[1];
                        f[i-1][i]=temp;
            }
            for(int i=1;i<=n;i++)
                        f[i][i]=0;
            for(int p=2;p<=n;p++)
                        for(int i=1;i<=n-p;i++)
                                    for(int j=i+1;j<=i+p;j++)
                                    {
                                                int k=1;
                                                while(1)
                                                {
                                                            if(j-k<=i) break;
                                                            if(a[j]-a[j-k]>d[3])break;
                                                            if(a[j]-a[j-k]>d[2])
                                                                        f[i][j]=min(f[i][j],f[i][j-k]+cost[3]);
                                                            else if(a[j]-a[j-k]>d[1])
                                                                        f[i][j]=min(f[i][j],f[i][j-k]+cost[2]);
                                                            else f[i][j]=min(f[i][j],f[i][j-k]+cost[1]);
                                                            k++;
                                                }
                                                k=1;
                                                while(1)
                                                {
                                                            if(i+k>=j) break;
                                                            if(a[i+k]-a[i]>d[3]) break;
                                                            if(a[i+k]-a[i]>d[2])
                                                                        f[i][j]=min(f[i][j],f[i+k][j]+cost[3]);
                                                            else if(a[i+k]-a[i]>d[1])
                                                                        f[i][j]=min(f[i][j],f[i+k][j]+cost[2]);
                                                            else f[i][j]=min(f[i][j],f[i+k][j]+cost[1]);
                                                            k++;
                                                }
                                    }
            int aaa=min(s,e);
            int bbb=max(e,s);
            cout<<f[aaa][bbb]<<endl;
            return 0;
}
Re: why WA #8??? help me
Послано cczzbb456 17 ноя 2010 18:13
i think you should solve it yourself..we got wronganswer because of bad thinking habit
Re: why WA #8??? help me
Послано Adhambek 30 окт 2014 08:36
try this test case:
1 2 3 1 2 3
2
2 1
1
ans = 1

Edited by author 30.10.2014 08:37