Submission #173324


Source Code Expand

Copy
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
		}

		long cases = 0;
		int prev = Integer.MIN_VALUE;
		int prevCount = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] != -1 && prev == Integer.MIN_VALUE) {
				prev = a[i];
				prevCount = 0;
				continue;
			} else if (a[i] != -1 && prev != Integer.MIN_VALUE){
				cases += conbination(a[i] - prev + prevCount, prevCount);
				prev = Integer.MIN_VALUE;
				continue;
			} else {
				prevCount++;
				continue;
			}
		}

		System.out.println(cases);
		
		sc.close();
	}
	
	static long conbination(int n, int r) {
		r = Math.min(n - r, r);

		double result = 1;
		for (int i = n; i >= n - r + 1; i--) {
			result *= i;
		}
		for (int i = 1; i <= r; i++) {
			result /= i;
		}

		return (long)result;
	}
}

Submission Info

Submission Time
Task C - タコヤ木
User garnacha
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 993 Byte
Status WA
Exec Time 579 ms
Memory 26224 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
AC × 2
WA × 1
AC × 4
WA × 10
AC × 6
WA × 20
AC × 6
WA × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, 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
Subtask2 sample_01.txt, 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, 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
Subtask3 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, 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, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt AC 440 ms 22228 KB
sample_02.txt AC 439 ms 22172 KB
sample_03.txt WA 428 ms 22096 KB
subtask1_01.txt AC 429 ms 22224 KB
subtask1_02.txt AC 430 ms 22228 KB
subtask1_03.txt WA 424 ms 22220 KB
subtask1_04.txt WA 427 ms 22364 KB
subtask1_05.txt WA 435 ms 22608 KB
subtask1_06.txt WA 442 ms 22600 KB
subtask1_07.txt WA 438 ms 22620 KB
subtask1_08.txt WA 471 ms 22444 KB
subtask1_09.txt WA 438 ms 22640 KB
subtask1_10.txt WA 440 ms 22488 KB
subtask1_11.txt WA 450 ms 22356 KB
subtask1_12.txt WA 433 ms 22480 KB
subtask2_01.txt AC 431 ms 22180 KB
subtask2_02.txt AC 428 ms 22100 KB
subtask2_03.txt WA 422 ms 22228 KB
subtask2_04.txt WA 456 ms 23128 KB
subtask2_05.txt WA 520 ms 24144 KB
subtask2_06.txt WA 464 ms 23000 KB
subtask2_07.txt WA 511 ms 24464 KB
subtask2_08.txt WA 550 ms 24600 KB
subtask2_09.txt WA 530 ms 24740 KB
subtask2_10.txt WA 524 ms 25464 KB
subtask2_11.txt WA 522 ms 24584 KB
subtask2_12.txt WA 536 ms 24752 KB
subtask3_01.txt AC 436 ms 22136 KB
subtask3_02.txt AC 432 ms 22100 KB
subtask3_03.txt WA 444 ms 22228 KB
subtask3_04.txt WA 560 ms 25392 KB
subtask3_05.txt WA 459 ms 22584 KB
subtask3_06.txt WA 544 ms 25228 KB
subtask3_07.txt WA 530 ms 24792 KB
subtask3_08.txt WA 563 ms 26224 KB
subtask3_09.txt WA 536 ms 24664 KB
subtask3_10.txt WA 546 ms 25872 KB
subtask3_11.txt WA 565 ms 24596 KB
subtask3_12.txt WA 579 ms 26000 KB