分析:
考察归并排序,用简单的快排会超时。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cctype>
#include <stack>
#include <map> using namespace std; // 归并排序 int a[];
int b[];
int c[]; int merge(int n, int m)
{
int i = , j = , k = ;
while (i < n && j < m)
{
if (a[i] > b[j])
c[k++] = b[j], j++;
else
c[k++] = a[i], i++;
}
while (i < n)
c[k++] = a[i], i++;
while (j < m)
c[k++] = b[j], j++;
return k;
} int main()
{
int n, m;
while (scanf("%d", &n) != EOF)
{
for (int i = ; i < n; i++)
scanf("%d", &a[i]); scanf("%d", &m);
for (int i = ; i < m; i++)
scanf("%d", &b[i]); int l = merge(n, m); if (l % == )
printf("%d\n", c[l >> ]);
else
printf("%d\n", c[(l - ) >> ]);
}
return ;
}