My program is right on my computer, but WA on acm.timus.ru, why?
Language:C++
Err On:URAL test 8
#include <iostream>
#include <stdio.h>
using namespace std;
struct Point{
long Dist,Money;
}a[11000];
int main(){
long L1,L2,L3,C1,C2,C3,n,i,j;
short Start,End;
scanf("%ld %ld %ld %ld %ld %ld %ld %ld %ld", &L1, &L2, &L3, &C1, &C2, &C3, &n, &Start, &End);
a[1].Dist=0;
for (i=2;i<=n;i++){
scanf("%ld", &a[i].Dist);
}
for (i=Start+1;i<=n;i++){
a[i].Money=2000000000;
}
a[Start].Money=0;
for (i=Start;i<=End;i++){
for (j=Start+1;j<=End;j++){
long Money;
if (a[j].Dist-a[i].Dist<=L1){
Money=C1;
} else if (a[j].Dist-a[i].Dist<=L2){
Money=C2;
} else if (a[j].Dist-a[i].Dist<=L3){
Money=C3;
} else {
Money=2000000000;
break;
}
if (a[i].Money+Money<a[j].Money){
a[j].Money=a[i].Money+Money;
}
}
}
printf("%ld\n", a[End].Money);
//return 0;
cin >> i;
}
Re: My program is right on my computer, but WA on acm.timus.ru, why?
I've got AC. pay attention to Start and End. If Start>End, you should swap them.