Submission #173326


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 && 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);

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

		if (result == 1) {
			result = 0;
		}
		return result;
	}
}

Submission Info

Submission Time
Task C - タコヤ木
User garnacha
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 1015 Byte
Status WA
Exec Time 671 ms
Memory 24272 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 × 3
WA × 11
AC × 5
WA × 21
AC × 5
WA × 31
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 671 ms 20224 KB
sample_02.txt AC 436 ms 20220 KB
sample_03.txt WA 435 ms 20280 KB
subtask1_01.txt WA 434 ms 20268 KB
subtask1_02.txt WA 434 ms 20344 KB
subtask1_03.txt AC 429 ms 20252 KB
subtask1_04.txt WA 456 ms 20732 KB
subtask1_05.txt WA 458 ms 20740 KB
subtask1_06.txt WA 448 ms 20440 KB
subtask1_07.txt WA 510 ms 20812 KB
subtask1_08.txt WA 441 ms 20860 KB
subtask1_09.txt WA 446 ms 20800 KB
subtask1_10.txt WA 445 ms 20652 KB
subtask1_11.txt WA 421 ms 20776 KB
subtask1_12.txt WA 437 ms 20728 KB
subtask2_01.txt WA 422 ms 20344 KB
subtask2_02.txt AC 430 ms 20212 KB
subtask2_03.txt AC 443 ms 20256 KB
subtask2_04.txt WA 472 ms 21160 KB
subtask2_05.txt WA 520 ms 22016 KB
subtask2_06.txt WA 474 ms 21188 KB
subtask2_07.txt WA 551 ms 22780 KB
subtask2_08.txt WA 552 ms 22652 KB
subtask2_09.txt WA 537 ms 22772 KB
subtask2_10.txt WA 552 ms 22736 KB
subtask2_11.txt WA 558 ms 22700 KB
subtask2_12.txt WA 569 ms 22812 KB
subtask3_01.txt WA 450 ms 20224 KB
subtask3_02.txt AC 434 ms 20356 KB
subtask3_03.txt WA 439 ms 20364 KB
subtask3_04.txt WA 579 ms 23944 KB
subtask3_05.txt WA 590 ms 20984 KB
subtask3_06.txt WA 533 ms 22952 KB
subtask3_07.txt AC 536 ms 22644 KB
subtask3_08.txt WA 569 ms 23864 KB
subtask3_09.txt WA 531 ms 22960 KB
subtask3_10.txt WA 550 ms 24272 KB
subtask3_11.txt WA 542 ms 23660 KB
subtask3_12.txt WA 543 ms 24128 KB