Skip to content

Instantly share code, notes, and snippets.

@yjfvictor
Created October 4, 2014 06:59
Show Gist options
  • Save yjfvictor/1aebe9564ef64ec927ce to your computer and use it in GitHub Desktop.
Save yjfvictor/1aebe9564ef64ec927ce to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <set>
using namespace std;
int main()
{
int case_count;
scanf("%d", &case_count);
for (int i = 1; i <= case_count; ++ i)
{
int n, cur;
multiset<int> s;
scanf("%*d%d", &n);
printf("%d %d\n", i, ((n>>1)+1));
for (int j = 0; j < n; ++ j)
{
scanf("%d", &cur);
s.insert(cur);
if ((j & 1) == 0)
{
int k;
multiset<int>::iterator itr;
int median_subscript = j >> 1;
for ( k = 0, itr= s.begin(); k < median_subscript; ++ itr, ++k)
{ }
if (j % 20 == 0)
{
if (j == 0 )
printf("%d", (*itr));
else
printf("\n%d", (*itr));
}
else
printf(" %d", (*itr));
}
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment