도와주세요 다른 친구랑 비교해봤는데

990299 Reply 8 years 26 weeks ago
과정이 거의 똑같거든요? 근데 왜 계속 83이 뜨는지 모르겠습니다 왜죠 도와주세요... 이거때문에 WA 한 열개는 받았네요 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int lenA = sc.nextInt(); int lenB = sc.nextInt(); int x = sc.nextInt(); int min1 = 10000; int min2 = 10000; int A[] = new int[lenA]; int B[] = new int[lenB]; for (int i = 0; i < lenA; i++) { A[i] = sc.nextInt(); } for (int i = lenB - 1; i >= 0; i--) { B[i] = sc.nextInt(); } int i = 0, j = 0; while(i < lenA && j < lenB) { if (x < A[i] + B[j]) { if (min1 > Math.abs(x - A[i] - B[j])) min1 = Math.abs(x - A[i] - B[j]); j++; } else if (x > A[i] + B[j]) { if (min1 > Math.abs(x - A[i] - B[j])) min1 = Math.abs(x - A[i] - B[j]); i++; } else { min1 = 0; break; } } i = lenA - 1; j = lenB - 1; while(i >= 0 && j >= 0) { if (x < A[i] + B[j]) { if (min2 > Math.abs(x - A[i] - B[j])) min2 = Math.abs(x - A[i] - B[j]); i--; } else if (x > A[i] + B[j]) { if (min2 > Math.abs(x - A[i] - B[j])) min2 = Math.abs(x - A[i] - B[j]); j--; } else { min2 = 0; break; } } System.out.print(Math.min(min1, min2)); } }
990299 Reply 8 years 26 weeks ago
해결했습니다
onacloud Reply 8 years 25 weeks ago
축하해요~ 이 Reply는 내껍니다. 꿀꺽