You are not logged in. Please login at www.codechef.com to post your questions!

×

getting wrong answer

why am i getting WA??

question-link text

solution-link text

asked 23 Jun '17, 08:51

avik26091998's gravatar image

2★avik26091998
11
accept rate: 0%


solution : https://www.codechef.com/viewsolution/14313209

mistake :

1) for(i=1;i<=n;++i) cin>>a[i];
sort(a,a+n);

sort() sorts from a[0] to a[n-1] and your input is from a[1] to a[n]

2) long min=a[n]; // I changed the array to operate from a[0] to a[n-1] so min = a[n-1]

link

answered 23 Jun '17, 09:42

dragonemperor's gravatar image

3★dragonemperor
89321135
accept rate: 10%

thanks!!!!

(23 Jun '17, 10:12) avik260919982★

https://www.codechef.com/viewsolution/14313839 question: life the universe the everthing

include <stdio.h>

int main(void) { int i; while (1) { scanf("%d", &i); if (i == 42) break; printf("%d", i); } return 0; }

link

answered 23 Jun '17, 11:56

anirudh12n96's gravatar image

0★anirudh12n96
1
accept rate: 0%

1

You are not printing each number in new line. Add '\n' in printf statement.

(23 Jun '17, 12:25) rjohari233★

Thanks :-)

(24 Jun '17, 11:39) anirudh12n960★

https://www.codechef.com/viewsolution/14319887

whats wrong with this code it says time limit exceeded

link

answered 24 Jun '17, 12:17

anirudh12n96's gravatar image

0★anirudh12n96
1
accept rate: 0%

First of all your array size if not according to constraint

(24 Jun '17, 13:17) ayushagg311★

Also, your logic doesn't seem correct to me.Modify it.

(24 Jun '17, 13:17) ayushagg311★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×3,820
×1,070
×801

question asked: 23 Jun '17, 08:51

question was seen: 260 times

last updated: 24 Jun '17, 13:17