看到一个错误的题解竟然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); } } |