Submission #1482391
Source Code Expand
// tested by Hightail - https://github.com/dj3500/hightail import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.math, std.typecons, std.container, core.bitop; import std.datetime, std.bigint; immutable long mod = 10^^9 + 7; int n; int[] t, a; void main() { scan(n); t = readln.split.to!(int[]); a = readln.split.to!(int[]); auto L = new int[](n); auto H = new int[](n); L[0] = H[0] = t[0]; foreach (i ; 1 .. n) { if (t[i - 1] < t[i]) { L[i] = H[i] = t[i]; } else { L[i] = 1; H[i] = t[i]; } } if (!(L[n - 1] <= a[n - 1] && a[n - 1] <= H[n - 1])) { writeln(0); return; } L[n - 1] = H[n - 1] = a[n - 1]; foreach_reverse (i ; 0 .. n - 1) { if (a[i] > a[i + 1]) { if (L[i] <= a[i] && a[i] <= H[i]) { L[i] = H[i] = a[i]; } else { writeln(0); return; } } else { if (L[i] == H[i]) { if (H[i] > a[i]) { writeln(0); return; } } else { H[i] = min(H[i], a[i]); } } } long ans = 1; foreach (i ; 0 .. n) { (ans *= (H[i] - L[i] + 1)) %= mod; } writeln(ans); } void scan(T...)(ref T args) { string[] line = readln.split; foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | nanae |
Language | D (DMD64 v2.070.1) |
Score | 400 |
Code Size | 1907 Byte |
Status | AC |
Exec Time | 54 ms |
Memory | 8392 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
0_003.txt | AC | 1 ms | 256 KB |
1_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 1 ms | 256 KB |
1_006.txt | AC | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 54 ms | 8392 KB |
1_009.txt | AC | 44 ms | 7956 KB |
1_010.txt | AC | 47 ms | 8308 KB |
1_011.txt | AC | 48 ms | 7800 KB |
1_012.txt | AC | 46 ms | 8136 KB |
1_013.txt | AC | 47 ms | 7620 KB |
1_014.txt | AC | 46 ms | 6580 KB |
1_015.txt | AC | 47 ms | 6252 KB |
1_016.txt | AC | 45 ms | 6200 KB |
1_017.txt | AC | 44 ms | 7332 KB |
1_018.txt | AC | 42 ms | 6240 KB |
1_019.txt | AC | 38 ms | 7440 KB |
1_020.txt | AC | 35 ms | 7016 KB |