제출 #429403

#제출 시각아이디문제언어결과실행 시간메모리
429403SansPapyrus683은행 (IZhO14_bank)Java
컴파일 에러
0 ms0 KiB
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Bank {
    public static void main(String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer initial = new StringTokenizer(read.readLine());
        int peopleNum = Integer.parseInt(initial.nextToken());
        int noteNum = Integer.parseInt(initial.nextToken());
        int[] people = Arrays.stream(read.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] banknotes = Arrays.stream(read.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int[] leftover = new int[1 << noteNum];
        int[] peopleCovered = new int[1 << noteNum];
        Arrays.fill(leftover, -1);
        Arrays.fill(peopleCovered, -1);
        leftover[0] = 0;
        peopleCovered[0] = 0;
        for (int s = 0; s < (1 << noteNum); s++) {
            for (int last = 0; last < noteNum; last++) {
                if ((s & (1 << last)) == 0) {
                    continue;
                }
                int prev = s & ~(1 << last);
                if (peopleCovered[prev] == -1) {
                    continue;
                }

                int new_amt = leftover[prev] + banknotes[last];
                int curr_target = people[peopleCovered[prev]];
                if (new_amt < curr_target) {
                    peopleCovered[s] = peopleCovered[prev];
                    leftover[s] = new_amt;
                } else if (new_amt == curr_target) {
                    peopleCovered[s] = peopleCovered[prev] + 1;
                    leftover[s] = 0;
                }
            }
            if (peopleCovered[s] == peopleNum) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}

컴파일 시 표준 에러 (stderr) 메시지

bank.java:7: error: class Bank is public, should be declared in a file named Bank.java
public class Bank {
       ^
1 error