Submission #16805182


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        n: usize,
        t: [i64; n],
        a: [i64; n],
    };
    let mut f = vec![0_i64; n];
    f[0] = t[0];
    let mut p = t[0];
    for (i, &t_i) in t.iter().enumerate().skip(1) {
        if p < t_i {
            f[i] = t_i;
        }
        p = t_i;
    }
    if f[n - 1] > 0 && f[n - 1] != a[n - 1] {
        println!("0");
        return;
    }
    f[n - 1] = a[n - 1];
    p = a[n - 1];
    for (i, &a_i) in a.iter().enumerate().rev().skip(1) {
        if f[i] > 0 && f[i] > a_i {
            println!("0");
            return;
        }
        if p < a_i {
            if f[i] > 0 && f[i] != a_i {
                println!("0");
                return;
            }
            f[i] = a_i;
        }
        p = a_i;
    }

    let mut ans = 1_i64;
    for (&f_i, (&t_i, &a_i)) in f.iter().zip(t.iter().zip(a.iter())) {
        if f_i == 0 {
            ans *= std::cmp::min(t_i, a_i);
            ans %= 1_000_000_007;
        }
    }
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - Two Alpinists
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 1028 Byte
Status AC
Exec Time 29 ms
Memory 6368 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 21
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 7 ms 2080 KB
0_001.txt AC 2 ms 2048 KB
0_002.txt AC 1 ms 1988 KB
0_003.txt AC 1 ms 2048 KB
1_004.txt AC 1 ms 2072 KB
1_005.txt AC 1 ms 2104 KB
1_006.txt AC 1 ms 2064 KB
1_007.txt AC 3 ms 2060 KB
1_008.txt AC 20 ms 5856 KB
1_009.txt AC 19 ms 6024 KB
1_010.txt AC 29 ms 5856 KB
1_011.txt AC 19 ms 6176 KB
1_012.txt AC 23 ms 6096 KB
1_013.txt AC 19 ms 6156 KB
1_014.txt AC 22 ms 6368 KB
1_015.txt AC 21 ms 5916 KB
1_016.txt AC 20 ms 6084 KB
1_017.txt AC 28 ms 5500 KB
1_018.txt AC 26 ms 5280 KB
1_019.txt AC 16 ms 5144 KB
1_020.txt AC 21 ms 4996 KB