## 11850 - Alaska

All about problems in Volume 118. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Rashad
New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

### 11850 - Alaska

I am getting WA. Can anyone give me any hints.

Leonid
Experienced poster
Posts: 146
Joined: Thu Dec 22, 2005 5:50 pm
Contact:

### 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.

Rashad
New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

### 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??

Leonid
Experienced poster
Posts: 146
Joined: Thu Dec 22, 2005 5:50 pm
Contact:

### 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?

Rashad
New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

### Re: 11850-Alaska

Got AC. Thanks Leonid.

Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

### Re: 11850-Alaska

wrong answer
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;
}
``````

Rashad
New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

### 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.

simple simon
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..??

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

### 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..

naseef_07cuet
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....

Shafaet_du
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.

naseef_07cuet
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....

uvasarker
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:

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;
}

``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11850-Alaska

Input:

Code: Select all

``````7
600
1400
400
1200
200
1000
0
0``````
Output is:

Code: Select all

``IMPOSSIBLE``
Check input and AC output for thousands of problems on uDebug!

uvasarker
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:

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;
}

``````