Submission #30205740


Source Code Expand

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

fn main() {
    input! {
        n: usize,
        cp: [(usize, usize); n],
        q: usize,
        lr: [(Usize1, Usize1); q],
    };
    let s1 = std::iter::once(0)
        .chain(cp.iter().scan(0, |acc, &(c, p)| {
            *acc += match c {
                1 => p,
                2 => 0,
                _ => unreachable!(),
            };
            Some(*acc)
        }))
        .collect::<Vec<usize>>();
    let s2 = std::iter::once(0)
        .chain(cp.iter().scan(0, |acc, &(c, p)| {
            *acc += match c {
                1 => 0,
                2 => p,
                _ => unreachable!(),
            };
            Some(*acc)
        }))
        .collect::<Vec<usize>>();
    for (l, r) in lr {
        println!("{} {}", s1[r + 1] - s1[l], s2[r + 1] - s2[l]);
    }
}

Submission Info

Submission Time
Task 095 - Score Sum Queries(★2)
User bouzuya
Language Rust (1.42.0)
Score 2
Code Size 834 Byte
Status AC
Exec Time 184 ms
Memory 8372 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 2 / 2
Status
AC × 4
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand01.txt, hand02.txt, hand03.txt, hand04.txt, hand05.txt, hand06.txt, random01.txt, random02.txt, random03.txt, random04.txt, random05.txt, random06.txt, random07.txt, random08.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand01.txt AC 5 ms 2052 KiB
hand02.txt AC 2 ms 2068 KiB
hand03.txt AC 183 ms 8292 KiB
hand04.txt AC 182 ms 8212 KiB
hand05.txt AC 170 ms 8212 KiB
hand06.txt AC 184 ms 8372 KiB
random01.txt AC 143 ms 5820 KiB
random02.txt AC 168 ms 6608 KiB
random03.txt AC 135 ms 4844 KiB
random04.txt AC 84 ms 3660 KiB
random05.txt AC 96 ms 4200 KiB
random06.txt AC 68 ms 3304 KiB
random07.txt AC 93 ms 3772 KiB
random08.txt AC 17 ms 2356 KiB
sample_01.txt AC 1 ms 2048 KiB
sample_02.txt AC 4 ms 2156 KiB
sample_03.txt AC 1 ms 1996 KiB
sample_04.txt AC 2 ms 2164 KiB