Submission #31643184


Source Code Expand

use proconio::{input, marker::Usize1};

fn adjacency_list(n: usize, uv: &[(usize, usize)]) -> Vec<Vec<usize>> {
    let mut e = vec![vec![]; n];
    for (u, v) in uv.iter().copied() {
        e[u].push(v);
    }
    e
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [i64; n],
        xy: [(Usize1, Usize1); m],
    };
    let edges = adjacency_list(n, &xy);
    let inf = 1_i64 << 60;
    let mut min = vec![inf; n];
    for u in 0..n {
        for v in edges[u].iter().copied() {
            min[v] = min[v].min(min[u].min(a[u]));
        }
    }
    let mut ans = -inf;
    for v in 0..n {
        ans = ans.max(a[v] - min[v]);
    }
    println!("{}", ans);
}

Submission Info

Submission Time
Task E - Peddler
User bouzuya
Language Rust (1.42.0)
Score 500
Code Size 690 Byte
Status AC
Exec Time 64 ms
Memory 23572 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 49
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All extreme_00.txt, extreme_01.txt, extreme_02.txt, extreme_03.txt, handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_dense_00.txt, random_dense_01.txt, random_dense_02.txt, random_dense_03.txt, random_dense_04.txt, random_dense_05.txt, random_dense_06.txt, random_dense_07.txt, random_dense_08.txt, random_dense_09.txt, random_small_00.txt, random_small_01.txt, random_small_02.txt, random_small_03.txt, random_small_04.txt, random_small_05.txt, random_small_06.txt, random_small_07.txt, random_small_08.txt, random_small_09.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
extreme_00.txt AC 64 ms 23572 KiB
extreme_01.txt AC 38 ms 17888 KiB
extreme_02.txt AC 48 ms 21140 KiB
extreme_03.txt AC 24 ms 11688 KiB
handmade_00.txt AC 2 ms 2128 KiB
handmade_01.txt AC 1 ms 2084 KiB
random_00.txt AC 43 ms 15296 KiB
random_01.txt AC 47 ms 15860 KiB
random_02.txt AC 24 ms 8868 KiB
random_03.txt AC 28 ms 8492 KiB
random_04.txt AC 23 ms 7460 KiB
random_05.txt AC 21 ms 9812 KiB
random_06.txt AC 12 ms 3636 KiB
random_07.txt AC 37 ms 11864 KiB
random_08.txt AC 42 ms 11972 KiB
random_09.txt AC 33 ms 13480 KiB
random_10.txt AC 18 ms 6588 KiB
random_11.txt AC 43 ms 16432 KiB
random_12.txt AC 32 ms 9848 KiB
random_13.txt AC 44 ms 16564 KiB
random_14.txt AC 33 ms 9648 KiB
random_15.txt AC 49 ms 17616 KiB
random_16.txt AC 31 ms 9972 KiB
random_17.txt AC 51 ms 18824 KiB
random_18.txt AC 9 ms 3872 KiB
random_19.txt AC 34 ms 14036 KiB
random_dense_00.txt AC 15 ms 5424 KiB
random_dense_01.txt AC 24 ms 8452 KiB
random_dense_02.txt AC 20 ms 7840 KiB
random_dense_03.txt AC 19 ms 7100 KiB
random_dense_04.txt AC 2 ms 2028 KiB
random_dense_05.txt AC 12 ms 3944 KiB
random_dense_06.txt AC 19 ms 8420 KiB
random_dense_07.txt AC 3 ms 2488 KiB
random_dense_08.txt AC 28 ms 9060 KiB
random_dense_09.txt AC 7 ms 3524 KiB
random_small_00.txt AC 2 ms 2060 KiB
random_small_01.txt AC 2 ms 2156 KiB
random_small_02.txt AC 1 ms 2116 KiB
random_small_03.txt AC 1 ms 1996 KiB
random_small_04.txt AC 1 ms 2108 KiB
random_small_05.txt AC 2 ms 2132 KiB
random_small_06.txt AC 1 ms 2016 KiB
random_small_07.txt AC 2 ms 1968 KiB
random_small_08.txt AC 2 ms 2192 KiB
random_small_09.txt AC 2 ms 2128 KiB
sample_01.txt AC 2 ms 2052 KiB
sample_02.txt AC 2 ms 2088 KiB
sample_03.txt AC 2 ms 2140 KiB