任何人都请帮我解决Java中的此问题 正如我尝试使用以下代码
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Arrays;
public class Solution1 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(System.out));
long testCases = Integer.parseInt(br.readLine());
int n;
long b;
int[] a;
int count;
for (int i = 1; i <= testCases; i++) {
String[] inputs = br.readLine().split(" ");
n = Integer.parseInt(inputs[0]);
a = new int[n];
b = Integer.parseInt(inputs[1]);
String[] input2 = br.readLine().split(" ");
for (int j = 0; j < n; j++)
a[j] = Integer.parseInt(input2[j]);
Arrays.sort(a);
count = 0;
for (int j = 0; j < n; j++) {
b = b - a[j];
if (b < 0) {
break;
}
count++;
}
bufferedWriter.write((String.format("Case #%d :%d", i, count)));
bufferedWriter.newLine();
}
br.close();
bufferedWriter.close();
}
}
我已经通过了所有测试用例,但是每当我提交代码时,示例都将失败:WA在结果中...。我不知道我在哪里留下了东西