
11850 - Alaska
Moderator: Board moderators
11850 - Alaska
I am getting WA. Can anyone give me any hints. 

Re: 11850-Alaska
Make sure that the range of the electric car is enough to travel from the Delta Junction to the nearest city with a fuel station and back.
Re: 11850-Alaska
Should I consider that her journey begins form 0 and ends at 1422? My algo is something like that: I am taking the input in an array & sort it. Then I am checking difference between index 0&1, 1&2, 2&3.... is<=200. Is it correct??
Re: 11850-Alaska
This is not enough, as according to the problem description you need to go back as well.
Can Brenda drive her car from Dawson City to Delta Juntion and back?
Re: 11850-Alaska
Got AC. Thanks Leonid. 

-
- New poster
- Posts: 12
- Joined: Wed Aug 18, 2010 12:07 pm
Re: 11850-Alaska
wrong answer
please send me some critical input
please send me some critical input
Code: Select all
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int sort(int a[],int n)
{
int i,j;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
if(a[j]>a[j+1])
{
int tmp=a[j];a[j]=a[j+1];a[j+1]=tmp;
}
}
return 0;
}
int main()
{
int n,i;
scanf("%d",&n);
while(n)
{
int a[2000],s=0;
//a[0]=1422;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,n);
a[n]=1422;
//for(i=0;i<n;i++)
// printf(" %d ",a[i]);
for(i=1;i<n-1;i++)
{
if(abs(a[i+1]-a[i])>200)
{s=1;break;}
}
if((a[0]-0)>100||(1422-a[n-1])>100)
s=1;
if(s)
printf("IMPOSSIBLE\n");
else printf("POSSIBLE\n");
scanf("%d",&n);
}
return 0;
}
Re: 11850-Alaska
You need not to check at a[0]. a[0]-0 can be greater than 100. if you have a charging station at 0 and at 150 you can travel. you have to check while returning. 

-
- New poster
- Posts: 2
- Joined: Fri Mar 05, 2010 12:12 pm
11850 - Alaska
i am getting wa in this problem.......but it seems easy to me........any suggestion or critical input plz..??
Re: 11850 - Alaska
Use the following thread..
http://acm.uva.es/board/viewtopic.php?f=53&t=50759
And do not make a new one..
http://acm.uva.es/board/viewtopic.php?f=53&t=50759
And do not make a new one..
-
- Learning poster
- Posts: 62
- Joined: Sat Nov 21, 2009 10:17 pm
- Location: CUET,Chittagong,Bangladesh
Re: 11850-Alaska
I think Rashed got the bug on your code...please follow him.....
If you have determination, you can do anything you want....

-
- Experienced poster
- Posts: 147
- Joined: Mon Jun 07, 2010 11:43 am
- Location: University Of Dhaka,Bangladesh
- Contact:
Re: 11850-Alaska
You cant return only if you cant reach the nearest station to delta junction while returning.
UVa stats: http://felix-halim.net/uva/hunting.php?id=63448
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
-
- Learning poster
- Posts: 62
- Joined: Sat Nov 21, 2009 10:17 pm
- Location: CUET,Chittagong,Bangladesh
Re: 11850-Alaska
I found this problem similar to 11608.
If you have determination, you can do anything you want....

-
- Learning poster
- Posts: 96
- Joined: Tue Jul 19, 2011 12:19 pm
- Location: Dhaka, Bangladesh
- Contact:
Re: 11850-Alaska
Please, Anyone will help me I am getting wrong answer.
Please give me some critical i/o test cases so that I can get rid of this problem.
Here is my code:
Please give me some critical i/o test cases so that I can get rid of this problem.
Here is my code:
Code: Select all
#include <cstdio>
int main()
{
long n;
while(scanf("%ld",&n)==1)
{
if(n==0) break;
long station[10000],I,J,fag=0;
for(I=0 ; I<n ; I++)
{
scanf("%ld",&station[I]);
if(station[I]>1222)
fag=1;
}
if(fag==1)
{
int dis=0;
for(J=0 ; J<n ; J++)
{
dis=station[I+1]-station[I];
if(dis>200 || dis<-200)
{
fag=0;
break;
}
}
if(fag==0)
printf("IMPOSSIBLE\n");
else
printf("POSSIBLE\n");
}
else
printf("IMPOSSIBLE\n");
fag=0;
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11850-Alaska
Input:
Output is:
Code: Select all
7
600
1400
400
1200
200
1000
0
0
Code: Select all
IMPOSSIBLE
Check input and AC output for thousands of problems on uDebug!
-
- Learning poster
- Posts: 96
- Joined: Tue Jul 19, 2011 12:19 pm
- Location: Dhaka, Bangladesh
- Contact:
Re: 11850-Alaska
Hi boss,
I am upset still WA. please help me:
Here is my code:
I am upset still WA. please help me:
Here is my code:
Code: Select all
#include <cstdio>
int main()
{
long n;
while(scanf("%ld",&n)==1)
{
if(n==0) break;
long station[100000],I,J,fag=1;
for(I=0 ; I<n ; I++)
{
scanf("%ld",&station[I]);
}
int dis=0;
for(J=0 ; J<n ; J++)
{
dis=station[J+1]-station[J];
if(dis>200 || dis<-200)
{
fag=0;
break;
}
}
if(fag==0)
printf("IMPOSSIBLE\n");
else
printf("POSSIBLE\n");
fag=1;
}
return 0;
}