Submission #3501630


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] h = in.nextIntArray(n);
			int[] up = new int[n+1], down = new int[n+1];
			for (int i = 0; i < n-1; i++) {
				if (h[i] < h[i+1]) {
					up[i+1] = up[i] + 1;
				}
			}

			for (int i = n-1; i > 0; i--) {
				if (h[i] < h[i-1]) {
					down[i] = down[i+1] + 1;
				}
			}

			int max = 0;
			for (int i = 0; i < n; i++) {
				max = Math.max(max, up[i+1] + down[i]);
				max = Math.max(max, up[i] + down[i+1]);
			}

			out.println(max + 1);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}

Submission Info

Submission Time
Task B - 山のデータ
User tutuz
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 3372 Byte
Status AC
Exec Time 283 ms
Memory 46864 KB

Judge Result

Set Name Sample Subtask1 Subtask2
Score / Max Score 0 / 0 30 / 30 70 / 70
Status
AC × 2
AC × 17
AC × 32
Set Name Test Cases
Sample subtask0-sample-01.txt, subtask0-sample-02.txt
Subtask1 subtask0-sample-01.txt, subtask0-sample-02.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt
Subtask2 subtask0-sample-01.txt, subtask0-sample-02.txt, subtask1-01.txt, subtask1-02.txt, subtask1-03.txt, subtask1-04.txt, subtask1-05.txt, subtask1-06.txt, subtask1-07.txt, subtask1-08.txt, subtask1-09.txt, subtask1-10.txt, subtask1-11.txt, subtask1-12.txt, subtask1-13.txt, subtask1-14.txt, subtask1-15.txt, subtask2-01.txt, subtask2-02.txt, subtask2-03.txt, subtask2-04.txt, subtask2-05.txt, subtask2-06.txt, subtask2-07.txt, subtask2-08.txt, subtask2-09.txt, subtask2-10.txt, subtask2-11.txt, subtask2-12.txt, subtask2-13.txt, subtask2-14.txt, subtask2-15.txt
Case Name Status Exec Time Memory
subtask0-sample-01.txt AC 71 ms 21332 KB
subtask0-sample-02.txt AC 74 ms 21204 KB
subtask1-01.txt AC 73 ms 20820 KB
subtask1-02.txt AC 72 ms 22868 KB
subtask1-03.txt AC 73 ms 18644 KB
subtask1-04.txt AC 73 ms 21460 KB
subtask1-05.txt AC 74 ms 20052 KB
subtask1-06.txt AC 74 ms 20948 KB
subtask1-07.txt AC 72 ms 19412 KB
subtask1-08.txt AC 71 ms 19924 KB
subtask1-09.txt AC 73 ms 17236 KB
subtask1-10.txt AC 83 ms 19284 KB
subtask1-11.txt AC 74 ms 19284 KB
subtask1-12.txt AC 72 ms 21844 KB
subtask1-13.txt AC 74 ms 20820 KB
subtask1-14.txt AC 72 ms 18004 KB
subtask1-15.txt AC 83 ms 18772 KB
subtask2-01.txt AC 125 ms 24404 KB
subtask2-02.txt AC 181 ms 33072 KB
subtask2-03.txt AC 202 ms 35220 KB
subtask2-04.txt AC 235 ms 44232 KB
subtask2-05.txt AC 241 ms 43208 KB
subtask2-06.txt AC 231 ms 45196 KB
subtask2-07.txt AC 246 ms 45136 KB
subtask2-08.txt AC 283 ms 43312 KB
subtask2-09.txt AC 250 ms 43220 KB
subtask2-10.txt AC 239 ms 45076 KB
subtask2-11.txt AC 247 ms 46484 KB
subtask2-12.txt AC 232 ms 44912 KB
subtask2-13.txt AC 253 ms 46864 KB
subtask2-14.txt AC 252 ms 44468 KB
subtask2-15.txt AC 245 ms 45736 KB