看到一个错误的题解竟然AC了...

importjava.util.*;
importjava.math.*;
importjava.io.*;
publicclassMain{
    staticStreamTokenizer in=newStreamTokenizer(newBufferedReader(newInputStreamReader(System.in)));
    publicstaticvoidmain(String[] args)throwsException {
        intn=getInt();
        Node nodes[]=newNode[n];
        for(inti=0;i<n;i++) {
            nodes[i]=newNode();
            nodes[i].x=getInt();
        }
        for(inti=0;i<n;i++) {
            nodes[i].y=getInt();
        }
        Arrays.sort(nodes);
        longsum=0;
        for(inti=0;i<n;i++) {
            sum+=nodes[i].x;
            if(sum>nodes[i].y) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
    staticintgetInt() throwsException {
        in.nextToken();
        return(int)in.nval;
    }
}
classNode implementsComparable{
    longx;
    longy;
    publicNode() {}
    publicNode(inta,intb) {
        x=a;
        y=b;
    }
    publicintcompareTo(Object arg0) {
        Node node=(Node)arg0;
        return(int)(this.y-node.y);
    }
     
}

扫一扫,把题目装进口袋

 牛客网,程序员必备求职神器
全部评论

相关推荐

牛客771574427号:恭喜你,华杰
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务