public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] nums1 = new int[n]; int[] nums2 = new int[n]; int[] nums3 = new int[n]; int l1 = 0; int l2 = 0; int l3 = 0; for(int j = 0;j < n;j++){ nums1[j] = sc.nextInt(); } for(int j = 0;j < n;j++){ nums2[j] = sc.nextInt(); } for(int j = 0;j < n;j++){ nums3[j] = sc.nextInt(); } Arrays.sort(nums1); Arrays.sort(nums2); Arrays.sort(nums3); int ans = 0; for(int i = 0;i < n;i++){ int min = Math.min(nums1[l1],Math.min(nums2[l2],nums3[l3])); if(min == nums1[l1]){ l1++; }else if(min == nums2[l2]){ l2++; }else { l3++; } ans = ans + min; } System.out.println(ans); } }
全部评论
(1) 回帖