import java.util.Arrays; import java.util.Scanner; public class Main1 { private static int index = 0; private static int replaceNum; private static int[] A; public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] arr1 = sc.nextLine().split(" "); String[] arr2 = sc.nextLine().split(" "); if (arr1 == null || arr2 == null || arr1.length == 0 || arr2.length == 0) { System.out.print("NO"); return; } A = new int[arr1.length]; int[] B = new int[arr2.length]; int i = 0; for (String s : arr1) { A[i++] = Integer.parseInt(s); } i = 0; for (String s : arr2) { B[i++] = Integer.parseInt(s); } findInA(A); Arrays.sort(B); if(findInB(B, index)) { //替换index的值 只能AC70% A[index] = replaceNum; } else if (findInB(B, index - 1)) { //考虑替换index-1的值 A[index - 1] = replaceNum; } if (isSorted(A)) { printArray(A); } else { System.out.print("NO"); } sc.close(); return; } private static void printArray(int[] a) { for (int i = 0; i < a.length; i++) { if (i != a.length - 1) System.out.print(a[i] + " "); else System.out.print(a[i]); } } private static boolean isSorted(int[] newA) { for (int i = 1; i < newA.length; i++) { if (newA[i] <= newA[i - 1]) { return false; } } return true; } private static boolean findInB(int[] b, int index) { int res = Integer.MIN_VALUE; for (int num : b) { if (index >= 1) { if (num > A[index - 1] && num < A[index + 1]) { res = Math.max(res, num); } } else if (index == 0) { if (num < A[index + 1]) { res = Math.max(res, num); } } } boolean result = res == Integer.MIN_VALUE ? false : true; if (result) { replaceNum = res; } return result; } private static void findInA(int[] a) { for (int i = 1; i < a.length; i++) { if (a[i - 1] >= a[i]) { index = i; } } } }