import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class b568 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
while(input.hasNext()){
int a = input.nextInt();
List<Integer> list = new ArrayList();
for(int i=0; i<a; i++){
list.add(input.nextInt());
}
int answer=0, temp=0;
for(int i=0; i<list.size(); i++){
temp += list.get(i);
for(int j=0; j<list.size(); j++){
if(i==j){
continue;
}
if(temp+list.get(j)<=700000){
temp += list.get(j);
}
}
if(answer<temp){
answer = temp;
}
temp =0 ;
}
System.out.println(""+answer);
}
}
}
您的程式被監控系統中斷,可能是程式無法正常結束所導致。
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at b568.main(b856.java:9)
看起來是在input的時候有問題,我在本地端編譯沒有問題T.T