Submission #2121245


Source Code Expand

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		int[] a=ir.nextIntArray(n);
		long ret=n;
		for(int i=0;i<n;i++){
			int p=i;
			while(i<n-1&&a[i]<a[i+1])
				i++;
			ret+=(long)(i-p+1)*(long)(i-p)/2;
		}
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

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

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Submission Info

Submission Time
Task C - 単調増加
User holeguma
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 3316 Byte
Status AC
Exec Time 96 ms
Memory 23508 KB

Judge Result

Set Name Sample Subtask0 All
Score / Max Score 0 / 0 40 / 40 60 / 60
Status
AC × 4
AC × 19
AC × 35
Set Name Test Cases
Sample sample0.txt, sample1.txt, sample2.txt, sample3.txt
Subtask0 sample0.txt, sample1.txt, sample2.txt, sample3.txt, subtask0_0.txt, subtask0_1.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt
All sample0.txt, sample1.txt, sample2.txt, sample3.txt, subtask0_0.txt, subtask0_1.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt
Case Name Status Exec Time Memory
sample0.txt AC 71 ms 20180 KB
sample1.txt AC 70 ms 18132 KB
sample2.txt AC 68 ms 18132 KB
sample3.txt AC 70 ms 20692 KB
subtask0_0.txt AC 74 ms 19284 KB
subtask0_1.txt AC 73 ms 20052 KB
subtask0_10.txt AC 74 ms 17236 KB
subtask0_11.txt AC 72 ms 19796 KB
subtask0_12.txt AC 73 ms 19412 KB
subtask0_13.txt AC 75 ms 21588 KB
subtask0_14.txt AC 74 ms 21456 KB
subtask0_2.txt AC 74 ms 20436 KB
subtask0_3.txt AC 72 ms 23508 KB
subtask0_4.txt AC 73 ms 19924 KB
subtask0_5.txt AC 72 ms 20948 KB
subtask0_6.txt AC 72 ms 20820 KB
subtask0_7.txt AC 73 ms 18004 KB
subtask0_8.txt AC 70 ms 19156 KB
subtask0_9.txt AC 82 ms 17748 KB
subtask1_0.txt AC 94 ms 18388 KB
subtask1_1.txt AC 83 ms 18260 KB
subtask1_10.txt AC 92 ms 19156 KB
subtask1_11.txt AC 93 ms 22100 KB
subtask1_12.txt AC 95 ms 21460 KB
subtask1_13.txt AC 91 ms 18772 KB
subtask1_14.txt AC 96 ms 20052 KB
subtask1_15.txt AC 91 ms 20052 KB
subtask1_2.txt AC 83 ms 16468 KB
subtask1_3.txt AC 89 ms 21972 KB
subtask1_4.txt AC 90 ms 19540 KB
subtask1_5.txt AC 91 ms 18644 KB
subtask1_6.txt AC 86 ms 21972 KB
subtask1_7.txt AC 90 ms 18772 KB
subtask1_8.txt AC 91 ms 19924 KB
subtask1_9.txt AC 88 ms 18516 KB