ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1031. Railway Tickets

why I got WA ?
Posted by gigglee 7 Nov 2002 14:11
Here is my sourse:

#include<iostream.h>

int main( )
{
  long l[4] ;
  long c[4] ;
  long dis[10001] ;
  long val[10001] ;
  for ( int i=1 ; i<=3 ; i++ )
    cin>>l[i] ;
  for ( int i=1 ; i<=3 ; i++ )
    cin>>c[i] ;
  int n ;
  int sp , tp ;
  cin>>n ;
  cin>>sp>>tp ;
  if ( sp>tp )
  {
    int temp=sp ;
    sp=tp ;
    tp=temp ;
  }
  dis[1]=0l ;
  for ( int i=2 ; i<=n ; i++ )
      cin>>dis[i] ;
  val[tp]=0l ;
  for ( int j=tp-1 ; j>=sp ; j-- )
  {
    val[j]=1000000001l;
    int q1=0 , q2=0 , q3=0 ;
    for ( int k=j+1 ; k<=tp ; k++ )
    {
      long q=dis[k]-dis[j] ;
      if ( q<=l[1] )
        q1=k ;
      else
        if ( q<=l[2] )
          q2=k ;
        else
          if ( q<=l[3] )
            q3=k ;
    }
    cout<<j<<' '<<q1<<' '<<q2<<' '<<q3<<endl ;
    if ( q1!=0 )
      val[j]=val[q1]+c[1]<val[j] ? val[q1]+c[1] : val[j] ;
    if ( q2!=0 )
      val[j]=val[q2]+c[2]<val[j] ? val[q2]+c[2] : val[j] ;
    if ( q3!=0 )
      val[j]=val[q3]+c[3]<val[j] ? val[q3]+c[3] : val[j] ;
    cout<<val[j]<<endl ;
  }
  cout<<val[sp]<<endl ;
}