Re: 11850-Alaska
Posted: Wed Feb 15, 2012 12:13 am
Input:
AC output:
Code: Select all
8
400
1200
800
0
600
1400
200
1000
0
Code: Select all
POSSIBLE
Code: Select all
8
400
1200
800
0
600
1400
200
1000
0
Code: Select all
POSSIBLE
Code: Select all
/* Removed */ AC
Code: Select all
8
0
200
400
600
800
900
1100
1300
0
Code: Select all
IMPOSSIBLE
Code: Select all
#include <iostream>
using namespace std;
int main ()
{
int n , lo[1430],count=1;
while(cin>>n&&n!=0)
{
count=1;
for (int i=0;i<n;i++)
{
cin>>lo[i];
}
for (int j=0;j<n;j++)
{
if (lo[j]>lo[j+1])
{
if (lo[j]-lo[j+1]<=200)
count++;
cout<<count<<endl;
}
else if (lo[j]<lo[j+1])
{
if (lo[j+1]-lo[j]<=200)
count++;
}
}
if (count==n) cout<<"POSSIBLE"<<endl;
else cout<<"IMPOSSIBLE"<<endl;
}
return 0;
}
Code: Select all
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int s;
while(cin >> s){
if(s == 0) break;
int station[s];
bool conse = true;
for(int i = 0; i < s; i++) cin >> station[i];
sort(station, station+s);
for(int i = 0; i < s-1; i++){
if(abs(station[i]-station[i+1]) != 200){
conse = false;
break;
}
}
if(conse) cout << "POSSIBLE" << endl;
else cout << "IMPOSSIBLE" << endl;
}
}
Code: Select all
8
1399
1200
1000
800
600
400
200
0
0
Code: Select all
#include<stdio.h>
int main()
{
long long int n, i,j, station[1435],temp,flag;
while(scanf("%lld",&n) && n!=0)
{
flag=1;
for(i=0;i<n;i++)
scanf("%lld",&station[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
if(station[j]<station[j+1])
{
temp=station[j];
station[j]=station[j+1];
station[j+1]=temp;
}
}
for(i=0;i<n-1;i++)
{
if((station[i]-station[i+1])>200)
{
flag=0;
break;
}
}
if(flag==0)
printf("IMPOSSIBLE\n");
else if(flag==1)
printf("POSSIBLE\n");
}
return 0;
}
Try inputCan Brenda drive her car from Dawson City to Delta Juntion and back?
Code: Select all
8
1300
1200
1000
800
600
400
200
0
0
Code: Select all
IMPOSSIBLE
Code: Select all
IMPOSSIBBLE