Skip to content

Commit

Permalink
Add solution of mxmedian (#31)
Browse files Browse the repository at this point in the history
Related to #2
  • Loading branch information
aptrishu authored and gopalgoel19 committed Oct 30, 2017
1 parent d203c10 commit 19c00b0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions codechef/mxmedian.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

int main() {
#ifndef ONLINE_JUDGE
freopen("inp.txt", "r", stdin);
#endif
int t, n, ans;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
vector<int> a(2*n);
for(int i = 0; i < 2*n; ++i) {
scanf("%d", &a[i]);
}
sort(a.begin(), a.end());
ans = a[n+n/2];
printf("%d\n", ans);
for(int i = 0; i < n; ++i) {
printf("%d %d ", a[i], a[i+n]);
}
printf("\n");
}
return 0;
}

0 comments on commit 19c00b0

Please sign in to comment.