题目描述
JAVA
BufferedReader会MLE,Scanner没事,请求各路大神解答
AC⬇️
import java.io.*;
import java.util.*;
public class Main{
public static int T;
public static int N;
public static int[] data = new int[5000002];
public static int ans;
public static void main(String[] args) throws IOException{
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Scanner sc = new Scanner(new BufferedInputStream(System.in));
T = sc.nextInt();
for(int i = 0; i < T; i++){
Arrays.fill(data, 0);
ans = 0;
N = sc.nextInt();
String ss = sc.next();
for(int j = 1; j <= N; j++){
data[j] = Character.digit(ss.charAt(j-1), 10) + data[j-1];
}
for(int j = 1; j <= N / 2 + 1; j++){
int a = (data[j + (N +1)/ 2 - 1] - data[j-1]);
ans = Math.max(ans, a);
}
System.out.printf("Case #%d: %d\n", i+1, ans);
}
}
}