import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param arr1 int整型一维数组
* @param arr2 int整型一维数组
* @return int整型
*/
public int getUpMedian (int[] arr1, int[] arr2) {
// write code here
int k = ((arr1.length + arr2.length + 1) >> 1);
int p1 = 0;
int p2 = 0;
int res = 0;
int account = 0;
while (p1 < arr1.length && p2 < arr2.length) {
if (arr1[p1] <= arr2[p2]) {
res = arr1[p1];
p1++;
}
else {
res = arr2[p2];
p2++;
}
account++;
if (account == k) {
return res;
}
}
while (account < k && p1 < arr1.length) {
res = arr1[p1];
account++;
p1++;
}
while (account < k && p2 < arr2.length) {
res = arr2[p2];
account++;
p2++;
}
return res;
}
}