50점에서 더이상 올라가지 않습니다 ㅜㅜ

marong142 Reply 9 years 2 weeks ago
import java.util.Scanner; public class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int i, j, k; int a=sc.nextInt(); int[] A = new int[a]; int b=sc.nextInt(); int[] B = new int[b]; int x = sc.nextInt(); int[] C = new int[a*b]; // kinds of A+B // input A and B for (i=0; i<a; i++) A[i] = sc.nextInt(); for (j=0; j<a; j++) B[j] = sc.nextInt(); k=0; // input A+B into C for (i=0; i<a; i++){ for (j=0; j<b; j++){ C[k] = A[i] + B[j]; k++; } } int diff = Math.abs(x-C[0]); for (k=1; k<a*b; k++){ if (diff > Math.abs(x-C[k])){ diff = Math.abs(x-C[k]); } } System.out.println(diff); } } 왜 롱앤서50까지인지 도저히 갈피를 못 잡겠습니다
withcs2 Reply 9 years 2 weeks ago
int[] C = new int[a*b] 이러케 하면 안돼여 너무 커서요. 배열이
withcs2 Reply 9 years 2 weeks ago
http://stackoverflow.com/questions/3038392/do-java-arrays-have-a-maximum-size