제출 #630636

#제출 시각아이디문제언어결과실행 시간메모리
630636coderInTraining은행 (IZhO14_bank)Java
컴파일 에러
0 ms0 KiB
import java.util.*; public class Main { public static void main (String[]args) { Scanner scan = new Scanner (System.in); int peopleNumber = scan.nextInt(); int bankNoteNumber = scan.nextInt(); int [] salaries = new int [peopleNumber]; for (int i = 0; i < peopleNumber; i++) { salaries[i] = scan.nextInt(); } int [] bankNotes = new int [bankNoteNumber]; for (int i = 0; i < bankNoteNumber; i++) { bankNotes[i] = scan.nextInt(); } int subsetNumber = (int)Math.pow(2, bankNoteNumber); int [] maxPrefix = new int [subsetNumber]; int [] leftOver = new int [subsetNumber]; Arrays.fill(maxPrefix, Integer.MIN_VALUE); Arrays.fill(leftOver, Integer.MIN_VALUE); maxPrefix[0] = 0; leftOver[0] = 0; int max = 0; for (int i = 0; i < subsetNumber; i++) { int peopleFinished = maxPrefix[i]; max = Math.max(max, peopleFinished); if (max == peopleNumber) { break; } if (peopleFinished == Integer.MIN_VALUE) { continue; } for (int j = 0; j < bankNoteNumber; j++) { // Checking if the current bank note has been unused if ((i & (1 << j)) == 0) { int currentPersonTarget = salaries[peopleFinished]; int currentBankNote = bankNotes[j]; int currentLeftOver = leftOver[i]; int newIndex = i + (int)Math.pow(2, j); if (currentLeftOver + currentBankNote < currentPersonTarget) { maxPrefix[newIndex] = maxPrefix[i]; leftOver[newIndex] = currentLeftOver + currentBankNote; } if (currentLeftOver + currentBankNote == currentPersonTarget) { maxPrefix[newIndex] = maxPrefix[i] + 1; leftOver[newIndex] = 0; } } } } if (max == peopleNumber) { System.out.println("YES"); } else { System.out.println("NO"); } } }

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

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