Submission #173328


Source Code Expand

Copy
import java.math.BigInteger;
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 && prevCount == 0) {
				prev = a[i];
//				prevCount = 0;
				continue;
			} else if (a[i] != -1 && prevCount != 0){
				cases += conbination(a[i] - prev + prevCount, prevCount);
				prev = a[i];
				prevCount = 0;
				continue;
			} else {
				prevCount++;
				continue;
			}
		}

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

		BigInteger result = new BigInteger("1");
		for (int i = n; i >= n - r + 1; i--) {
			result = result.multiply(new BigInteger(Integer.toString(i)));
		}
		for (int i = 1; i <= r; i++) {
			result = result.divide(new BigInteger(Integer.toString(i)));
		}

		result = result.mod(new BigInteger(Integer.toString(1000000007)));

		if (result.equals(BigInteger.ONE)) {
			result = BigInteger.ZERO;
		}
		return result.longValue();
	}
}

Submission Info

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

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
AC × 3
AC × 4
WA × 10
AC × 7
WA × 19
AC × 8
WA × 28
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 783 ms 22760 KB
sample_02.txt AC 471 ms 22844 KB
sample_03.txt AC 467 ms 22948 KB
subtask1_01.txt WA 496 ms 22552 KB
subtask1_02.txt WA 507 ms 22468 KB
subtask1_03.txt AC 483 ms 22940 KB
subtask1_04.txt WA 506 ms 23352 KB
subtask1_05.txt WA 503 ms 23388 KB
subtask1_06.txt WA 487 ms 23356 KB
subtask1_07.txt AC 500 ms 23148 KB
subtask1_08.txt WA 500 ms 22720 KB
subtask1_09.txt WA 487 ms 23272 KB
subtask1_10.txt WA 507 ms 23096 KB
subtask1_11.txt WA 491 ms 23096 KB
subtask1_12.txt WA 487 ms 23080 KB
subtask2_01.txt WA 482 ms 22464 KB
subtask2_02.txt AC 492 ms 22844 KB
subtask2_03.txt AC 475 ms 22816 KB
subtask2_04.txt WA 516 ms 23736 KB
subtask2_05.txt WA 565 ms 24676 KB
subtask2_06.txt WA 573 ms 23824 KB
subtask2_07.txt AC 705 ms 30912 KB
subtask2_08.txt WA 618 ms 25264 KB
subtask2_09.txt WA 584 ms 25688 KB
subtask2_10.txt WA 642 ms 25920 KB
subtask2_11.txt WA 606 ms 26136 KB
subtask2_12.txt WA 599 ms 25816 KB
subtask3_01.txt WA 476 ms 22464 KB
subtask3_02.txt AC 475 ms 22836 KB
subtask3_03.txt AC 476 ms 22840 KB
subtask3_04.txt WA 632 ms 26748 KB
subtask3_05.txt WA 512 ms 23488 KB
subtask3_06.txt WA 607 ms 26560 KB
subtask3_07.txt AC 832 ms 31416 KB
subtask3_08.txt WA 630 ms 27100 KB
subtask3_09.txt WA 585 ms 25308 KB
subtask3_10.txt WA 615 ms 27128 KB
subtask3_11.txt WA 664 ms 27080 KB
subtask3_12.txt WA 662 ms 27020 KB