제출 #781084

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
7810842023-07-12 17:22:51sushikid은행 (IZhO14_bank)Java
100 / 100
330 ms40832 KiB
import java.util.*;
import java.io.*;
public class bank {
public static void main(String[] args) throws IOException{
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StringTokenizer st = new StringTokenizer(r.readLine());
int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken());
int[] salarys = new int[n];
int[] banknotes= new int[m];
st = new StringTokenizer(r.readLine());
for (int i = 0; i < n; i++) {
salarys[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(r.readLine());
for (int i = 0; i < m; i++) {
banknotes[i] = Integer.parseInt(st.nextToken());
}
int[][] dp = new int[1 << m][2]; //[cur i you're trying to complete, cur sum]
for (int i = 1; i < (1 << m); i++) {
int max_idx = 0;
int sum = 0;
for (int j = 0; j < m; j++) {
if((i & (1 << j)) != 0){
int idx = i - (1 << j);
int temp_idx = dp[idx][0];
int temp_sum = dp[idx][1];
if(dp[idx][1] + banknotes[j] < salarys[dp[idx][0]]){
temp_sum += banknotes[j];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...