public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> arrayList1 = new ArrayList<>();
ArrayList<Integer> arrayList2 = new ArrayList<>();
String[] s = scanner.nextLine().split(" ");
for (String s1 : s) {
String[] split = s1.split(",");
arrayList1.add(Integer.parseInt(split[0]));
arrayList2.add(Integer.parseInt(split[1]));
}
getMax(arrayList1, arrayList2, 0, 0, 0);
for (int i = 0; i < res.size(); i++) {
if (i < res.size() - 1) {
System.out.print(res.get(i) + " ");
} else {
System.out.print(res.get(i));
}
}
}
public static int sum = Integer.MIN_VALUE;
public static int W = 20;
public static ArrayList<Integer> tmp = new ArrayList<>();
public static ArrayList<Integer> res;
public static void getMax(ArrayList<Integer> arrayList1, ArrayList<Integer> arrayList2, int i, int num1, int num2) {
int n = arrayList1.size();
if (num1 > W) {
return;
}
if (i >= n) {
if (num2 > sum) {
sum = num2;
res = new ArrayList<>();
for (Integer integer : tmp) {
res.add(integer);
}
}
return;
}
for (int j = 0; j <= 1; j++) {
if (j == 0) {
tmp.add(0);
getMax(arrayList1, arrayList2, i + 1, num1, num2);
tmp.remove(tmp.size() - 1);
} else if (j == 1) {
tmp.add(1);
getMax(arrayList1, arrayList2, i + 1, num1 + arrayList1.get(i), num2 + arrayList2.get(i));
tmp.remove(tmp.size() - 1);
}
}
}
#网易雷火##网易雷火2023秋招笔试虐我的瞬间#
#笔试##网易雷火游戏测试#