Home | Problems | Discuss | Login

  

Java为什么提交不上去呢

4601: 机智的Glory

liuyihe | 2019-05-07 11:45:54 | delete | edit
提交的时候,注意 把 bufferedReader. read() 换成 bufferedReader.read() 
liuyihe | 2019-05-07 11:45:15 | delete | edit
为什么java不能提交呢? 提交的时候就转到一个不能连接的界面?

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out1 = new PrintWriter(new OutputStreamWriter(System.out));

		int MAXNN = 100010;
		int ans1[] = new int[MAXNN];
		int ans2[] = new int[MAXNN];
		char str2[] = new char[MAXNN];
		int lenstr2 = 0;

		int num = 0;
		int ch;
		
		while( (ch = bufferedReader. read()) != -1) {
			if( ch=='\n') {
				break;
			}
			if( ch=='\r') {
				continue;
			}
			if( ch == ' ' ||ch == '\t') {
				continue;
			}
			num = num * 10 + (ch - (int)'0') ; 
		}

		while (num-- > 0) {
			lenstr2 = 0;
			while( (ch = bufferedReader. read()) != -1) {
				if( ch=='\n') {
					break;
				}
				if( ch == ' ' ||ch == '\t' || ch == '\r') {
					continue;
				}
				str2[lenstr2++] = (char)ch;
			}
			
			int[] temp = new int[10];
			for (int i = 0; i < 10; i++) {
				temp[i] = 0;
			}
			for (int i = 0; i < lenstr2; i++) {
				int nowi = str2[i] - '0';
				int tempnow = 0;
				for (int j = 0; j <= nowi; j++) {
					if (temp[j] > tempnow) {
						tempnow = temp[j];
					}
				}
				temp[nowi] = tempnow + 1;
				ans1[i] = temp[nowi];
			}

			for (int i = 0; i < 10; i++) {
				temp[i] = 0;
			}
			for (int i = lenstr2 - 1; i >= 0; i--) {
				int nowi = str2[i] - '0';
				int tempnow = 0;
				for (int j = nowi; j <= 9; j++) {
					if (temp[j] > tempnow) {
						tempnow = temp[j];
					}
				}
				temp[nowi] = tempnow + 1;
				ans2[i] = temp[nowi];
			}

			int ans = 0;
			for (int i = 1; i < lenstr2; i++) {
				if (ans1[i - 1] + ans2[i] > ans) {
					ans = ans1[i - 1] + ans2[i];
				}
			}

			out1.println(ans);
			out1.flush();
		}
	}
} 

Please login to reply.