getting wrong answer

why am i getting WA??

question-link text

solution-link text

solution :

mistake :

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


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

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

question: life the universe the everthing
#include <stdio.h>
int main(void)
int i;
while (1) {
scanf("%d", &i);
if (i == 42)
printf("%d", i);
return 0;

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

1 Like

Thanks :slight_smile:

whats wrong with this code
it says time limit exceeded

First of all your array size if not according to constraint

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