PAT1029. Median

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>
#include <string>
#include <queue>

using namespace std;

int S1[1000005];
int S2[1000005];
int S3[2000010];
int main()
{
	int N1,N2;
	scanf("%d",&N1);
	for(int i=0;i<N1;i++)
		scanf("%d",S1+i);
	scanf("%d",&N2);
	for(int i=0;i<N2;i++)
		scanf("%d",S2+i);

	merge(S1,S1+N1,S2,S2+N2,S3);
	int median = S3[(N1+N2-1)/2];
	printf("%d",median);

	return 0;
}



你可能感兴趣的:(PAT1029. Median)