답안 #659150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
659150 2022-11-16T19:26:01 Z zhing_zhou Cipele (COCI18_cipele) Java 11
컴파일 오류
0 ms 0 KB
import java.util.*;
public class Cipele
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int a[] = new int[n];
        int b[] = new int[m];
        for(int i = 0; i < n; i++)
        {
            a[i] = sc.nextInt();
        }
        for(int i = 0; i < m; i++)
        {
            b[i] = sc.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int l = 0, r = 1000000000;
        int ans = r;
        while(l <= r)
        {
            int mid = (l + r) / 2;
            int pos = 0;
            boolean condition = true;
            for(int i = 0; i < Math.min(n, m); i++)
            {
                if(pos == Math.max(m, n))
                {
                    condition = false;
                    break;
                }
                if(n == Math.min(n, m))
                {
                    if(Math.abs(b[pos] - a[i]) <= mid)
                    {
                        pos++;
                        continue;
                    }
                }
                if(m == Math.min(n, m))
                {
                    if(Math.abs(a[pos] - b[i]) <= mid)
                    {
                        pos++;
                        continue;
                    }
                }
                i--;
                pos++;
            }
            if(condition == true)
            {
                r = mid - 1;
                ans = mid;
            }
            else
            {
                l = mid + 1;
            }
        }
        System.out.println(ans);
    }
}

Compilation message

cipele.java:2: error: class Cipele is public, should be declared in a file named Cipele.java
public class Cipele
       ^
1 error