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
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Wed Feb 15, 2012 12:13 am
Input:
Code: Select all
8
400
1200
800
0
600
1400
200
1000
0
AC output:
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:
Post
by uvasarker » Sat Feb 18, 2012 5:54 am
Hi
Boss,
I updated more. But
Still WA. Please help me. Here is my code:
@li_kuet
New poster
Posts: 44 Joined: Fri May 25, 2012 6:22 pm
Location: Chittagong, Bangladesh
Post
by @li_kuet » Mon Oct 01, 2012 5:43 pm
Try this Input :
Code: Select all
8
0
200
400
600
800
900
1100
1300
0
Output :
omarking05
New poster
Posts: 3 Joined: Sat Dec 08, 2012 5:16 pm
Post
by omarking05 » Sun Feb 10, 2013 4:15 pm
hey ..
can anybody tell me please whats wrong with my code ?
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;
}
thanks in advance ..
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Mon Feb 11, 2013 11:05 pm
Don't print count.
Check input and AC output for thousands of problems on
uDebug !
milan_aiub
New poster
Posts: 1 Joined: Sun Jun 24, 2012 1:02 pm
Post
by milan_aiub » Sun Mar 03, 2013 9:46 am
8
0
200
400
600
800
900
1100
1300
0
Why the output of this case is "IMPOSSIBLE" ?
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Mon Mar 04, 2013 11:17 pm
She can't make it from the station at 1300 miles to Delta Junction at 1422 miles and back to the station at 1300 miles.
Check input and AC output for thousands of problems on
uDebug !
MNT.95
New poster
Posts: 7 Joined: Thu Jan 23, 2014 5:40 pm
Post
by MNT.95 » Thu Feb 06, 2014 1:45 pm
I don't get the point of coming back ??
I sort them then I check the difference between them, every test case I run in my program is correct, so why I got WA?
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Thu Feb 06, 2014 11:10 pm
You can't assume there is a charging station at Delta Junction.
Check input and AC output for thousands of problems on
uDebug !
ultima_key
New poster
Posts: 10 Joined: Tue Mar 25, 2014 12:50 pm
Post
by ultima_key » Sat Mar 29, 2014 12:43 pm
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;
}
}
Why is my code returning a WA verdict? Every input I saw here was correct.
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Tue Apr 01, 2014 1:57 am
Input:
Code: Select all
8
1399
1200
1000
800
600
400
200
0
0
AC output: POSSIBLE
Check input and AC output for thousands of problems on
uDebug !
uDebug
A great helper
Posts: 475 Joined: Tue Jul 24, 2012 4:23 pm
Post
by uDebug » Tue Apr 01, 2014 9:52 am
Replying to follow the thread.
Shahidul.CSE
Experienced poster
Posts: 148 Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh
Post
by Shahidul.CSE » Sun Jul 20, 2014 12:16 am
Why WA with my code ?
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;
}
lighted
Guru
Posts: 587 Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek
Post
by lighted » Sun Jul 20, 2014 12:47 pm
The problem description says:
Can Brenda drive her car from Dawson City to Delta Juntion and back ?
Try input
Code: Select all
8
1300
1200
1000
800
600
400
200
0
0
Correct output is
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Shahidul.CSE
Experienced poster
Posts: 148 Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh
Post
by Shahidul.CSE » Sun Jul 20, 2014 3:12 pm
For above input, how the output be
please explain it.