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

Submission #173331

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

return result.longValue();
}
}
```

#### Submission Info

Submission Time 2014-05-21 11:32:26+0900 C - タコヤ木 garnacha Java (OpenJDK 1.7.0) 100 1234 Byte AC 806 ms 31292 KB

#### Judge Result

Score / Max Score 0 / 0 50 / 50 30 / 30 20 / 20
Status
 AC × 3
 AC × 14
 AC × 26
 AC × 36
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
sample_01.txt AC 806 ms 22876 KB
sample_02.txt AC 453 ms 22844 KB
sample_03.txt AC 445 ms 22844 KB
subtask1_01.txt AC 439 ms 22440 KB
subtask1_02.txt AC 438 ms 22592 KB
subtask1_03.txt AC 445 ms 22844 KB
subtask1_04.txt AC 480 ms 23224 KB
subtask1_05.txt AC 465 ms 23392 KB
subtask1_06.txt AC 472 ms 23352 KB
subtask1_07.txt AC 469 ms 23352 KB
subtask1_08.txt AC 464 ms 23100 KB
subtask1_09.txt AC 456 ms 23004 KB
subtask1_10.txt AC 467 ms 23360 KB
subtask1_11.txt AC 468 ms 23368 KB
subtask1_12.txt AC 470 ms 23264 KB
subtask2_01.txt AC 439 ms 22588 KB
subtask2_02.txt AC 526 ms 22752 KB
subtask2_03.txt AC 463 ms 22816 KB
subtask2_04.txt AC 513 ms 23868 KB
subtask2_05.txt AC 555 ms 24644 KB
subtask2_06.txt AC 514 ms 23880 KB
subtask2_07.txt AC 686 ms 30976 KB
subtask2_08.txt AC 568 ms 25104 KB
subtask2_09.txt AC 570 ms 25952 KB
subtask2_10.txt AC 581 ms 26308 KB
subtask2_11.txt AC 576 ms 26584 KB
subtask2_12.txt AC 573 ms 25804 KB
subtask3_01.txt AC 444 ms 22564 KB
subtask3_02.txt AC 457 ms 22840 KB
subtask3_03.txt AC 451 ms 22844 KB
subtask3_04.txt AC 600 ms 26908 KB
subtask3_05.txt AC 469 ms 23480 KB
subtask3_06.txt AC 585 ms 26688 KB
subtask3_07.txt AC 715 ms 31292 KB
subtask3_08.txt AC 588 ms 26296 KB
subtask3_09.txt AC 557 ms 25372 KB
subtask3_10.txt AC 584 ms 26868 KB
subtask3_11.txt AC 641 ms 26936 KB
subtask3_12.txt AC 621 ms 27328 KB