阿里8.23第一题,求大指点哪里不对

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);
    }
}

#阿里笔试##阿里巴巴#
全部评论
Long类型保存ans
点赞 回复 分享
发布于 2021-08-24 08:51

相关推荐

头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
八股刚起步,看了javaguide,小林coding,还有面渣,感觉面渣是体验最好的,请问只看面渣够用吗,有不完善的需要补吗?
码农索隆:先背最基础的知识,然后理解情景题,现在面试大多数喜欢问情景题,更考验面试者的基础和临场发挥情况
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务