22
糖果分配
http://www.nowcoder.com/questionTerminal/c0e676f4cf9846c785ade34d9472951b
import java.util.Arrays; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[]child = strToArray(sc.nextLine().split(" ")); int[]candy = strToArray(sc.nextLine().split(" ")); int i=0,j=0,cnt=0; while(i<child.length && j<candy.length) { if(child[i]<=candy[j]) { ++i; ++cnt; } ++j; } System.out.println(cnt); } public static int max(int... a) { return Arrays.stream(a).max().getAsInt(); } public static int[] strToArray(String[] a) { int[]p = Arrays.stream(a).mapToInt(Integer::valueOf).toArray(); return p; } }