Contest Duration: - (local time) (90 minutes) Back to Home

Submission #173329

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 = 1;
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 % 1000000007);

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 2014-05-21 11:23:08+0900 C - タコヤ木 garnacha Java (OpenJDK 1.7.0) 0 1296 Byte WA 909 ms 30908 KB

#### Judge Result

Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
 AC × 2 WA × 1
 AC × 6 WA × 8
 AC × 11 WA × 15
 AC × 15 WA × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 909 ms 22432 KB
sample_02.txt WA 425 ms 22484 KB
sample_03.txt AC 448 ms 22504 KB
subtask1_01.txt AC 443 ms 22248 KB
subtask1_02.txt AC 426 ms 22172 KB
subtask1_03.txt AC 422 ms 22612 KB
subtask1_04.txt WA 432 ms 23000 KB
subtask1_05.txt WA 439 ms 22948 KB
subtask1_06.txt WA 447 ms 22736 KB
subtask1_07.txt AC 467 ms 22744 KB
subtask1_08.txt AC 449 ms 22436 KB
subtask1_09.txt WA 439 ms 22996 KB
subtask1_10.txt WA 448 ms 22736 KB
subtask1_11.txt WA 448 ms 22736 KB
subtask1_12.txt WA 438 ms 22740 KB
subtask2_01.txt AC 425 ms 22100 KB
subtask2_02.txt AC 440 ms 22464 KB
subtask2_03.txt AC 437 ms 22372 KB
subtask2_04.txt WA 474 ms 23512 KB
subtask2_05.txt WA 522 ms 24408 KB
subtask2_06.txt WA 471 ms 23756 KB
subtask2_07.txt AC 633 ms 30540 KB
subtask2_08.txt AC 560 ms 25172 KB
subtask2_09.txt WA 536 ms 24940 KB
subtask2_10.txt WA 578 ms 25684 KB
subtask2_11.txt WA 558 ms 26100 KB
subtask2_12.txt WA 564 ms 25448 KB
subtask3_01.txt AC 437 ms 22116 KB
subtask3_02.txt AC 427 ms 22496 KB
subtask3_03.txt AC 434 ms 22492 KB
subtask3_04.txt WA 574 ms 27264 KB
subtask3_05.txt WA 465 ms 23124 KB
subtask3_06.txt WA 588 ms 26276 KB
subtask3_07.txt AC 732 ms 30908 KB
subtask3_08.txt AC 559 ms 25992 KB
subtask3_09.txt WA 525 ms 25040 KB
subtask3_10.txt WA 619 ms 26768 KB
subtask3_11.txt WA 579 ms 26704 KB
subtask3_12.txt WA 584 ms 26400 KB