Discuss Computer Science and Programming related problems
Moderators:Labib, bristy1588
-
HandaramTheGreat - Posts:135
- Joined:Thu Dec 09, 2010 12:10 pm
SPOJ8061
Unread post
by HandaramTheGreat » Mon Dec 27, 2010 1:05 pm
in which case it's getting WA?
problem statement::
my code::
Code: Select all
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int t, n, k, i, j, h[30000];
scanf("%d", &t);
for(i=1; i<=t; i++)
{
scanf("%d %d", &n, &k);
for(j=0; j<n; j++)
{
scanf("%d", &h[j]);
}
sort(h, h+n);
printf("%d\n", h[n-1]-h[n-k]);
}
return 0;
}
-
Zzzz
- Posts:172
- Joined:Tue Dec 07, 2010 6:28 am
- Location:22° 48' 0" N / 89° 33' 0" E
Unread post
by Zzzz » Mon Dec 27, 2010 5:27 pm
1
4 3
1 2 3 6
Correct output: 2 (if you select the students of height 1,2,3)
-
Hasib - Posts:238
- Joined:Fri Dec 10, 2010 11:29 am
- Location:খুলনা, বাংলাদেশ
-
Contact:
Unread post
by Hasib » Mon Dec 27, 2010 8:46 pm
I think it's c++. Am i ri8?
A man is not finished when he's defeated, he's finished when he quits.
-
Zzzz
- Posts:172
- Joined:Tue Dec 07, 2010 6:28 am
- Location:22° 48' 0" N / 89° 33' 0" E
Unread post
by Zzzz » Tue Dec 28, 2010 5:32 am
hasib.mo wrote:I think it's c++. Am i ri8?
humm...