阿里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

相关推荐

不愿透露姓名的神秘牛友
07-07 18:05
点赞 评论 收藏
分享
05-22 12:44
已编辑
门头沟学院 golang
点赞 评论 收藏
分享
半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
本2硕9,秋招不想努力海投了
小何和:行情再不好也不可能拒绝你,不可能只要双9的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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