QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#853230#9736. Kind of Bingoucup-team296#AC ✓3ms2844kbRust21.7kb2025-01-11 16:14:132025-01-11 16:14:13

Judging History

你现在查看的是最新测评结果

  • [2025-01-11 16:14:13]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:2844kb
  • [2025-01-11 16:14:13]
  • 提交

answer

// https://contest.ucup.ac/contest/1893/problem/9736
use crate::algo_lib::collections::vec_ext::inc_dec::IncDec;
use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::Output;
use crate::algo_lib::misc::test_type::TaskType;
use crate::algo_lib::misc::test_type::TestType;
type PreCalc = ();
fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &mut PreCalc) {
    let n = input.read_size();
    let m = input.read_size();
    let k = input.read_size();
    let p = input.read_size_vec(n * m).dec();
    if k >= m {
        out.print_line(m);
        return;
    }
    let req = m - k;
    let mut qty = vec![0; n];
    for i in 0..n * m {
        qty[p[i] / m] += 1;
        if qty[p[i] / m] == req {
            out.print_line((i + 1).max(m));
            return;
        }
    }
    unreachable!();
}
pub static TEST_TYPE: TestType = TestType::MultiNumber;
pub static TASK_TYPE: TaskType = TaskType::Classic;
pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    let mut pre_calc = ();
    match TEST_TYPE {
        TestType::Single => solve(&mut input, &mut output, 1, &mut pre_calc),
        TestType::MultiNumber => {
            let t = input.read();
            for i in 1..=t {
                solve(&mut input, &mut output, i, &mut pre_calc);
            }
        }
        TestType::MultiEof => {
            let mut i = 1;
            while input.peek().is_some() {
                solve(&mut input, &mut output, i, &mut pre_calc);
                i += 1;
            }
        }
    }
    output.flush();
    match TASK_TYPE {
        TaskType::Classic => input.is_empty(),
        TaskType::Interactive => true,
    }
}


fn main() {
    let mut sin = std::io::stdin();
    let input = crate::algo_lib::io::input::Input::new(&mut sin);
    let mut stdout = std::io::stdout();
    let output = crate::algo_lib::io::output::Output::new(&mut stdout);
    run(input, output);
}
pub mod algo_lib {
pub mod collections {
pub mod vec_ext {
pub mod default {
pub fn default_vec<T: Default>(len: usize) -> Vec<T> {
    let mut v = Vec::with_capacity(len);
    for _ in 0..len {
        v.push(T::default());
    }
    v
}
}
pub mod inc_dec {
use crate::algo_lib::numbers::num_traits::algebra::{AdditionMonoidWithSub, One};
pub trait IncDec {
    #[must_use]
    fn inc(self) -> Self;
    #[must_use]
    fn dec(self) -> Self;
}
impl<T: AdditionMonoidWithSub + One> IncDec for T {
    fn inc(self) -> Self {
        self + T::one()
    }
    fn dec(self) -> Self {
        self - T::one()
    }
}
impl<T: AdditionMonoidWithSub + One> IncDec for Vec<T> {
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|i| *i += T::one());
        self
    }
    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|i| *i -= T::one());
        self
    }
}
impl<T: AdditionMonoidWithSub + One> IncDec for Vec<Vec<T>> {
    fn inc(mut self) -> Self {
        self.iter_mut().for_each(|v| v.iter_mut().for_each(|i| *i += T::one()));
        self
    }
    fn dec(mut self) -> Self {
        self.iter_mut().for_each(|v| v.iter_mut().for_each(|i| *i -= T::one()));
        self
    }
}
impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One> IncDec
for Vec<(T, U)> {
    fn inc(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j)| {
                *i += T::one();
                *j += U::one();
            });
        self
    }
    fn dec(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j)| {
                *i -= T::one();
                *j -= U::one();
            });
        self
    }
}
impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V> IncDec
for Vec<(T, U, V)> {
    fn inc(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j, _)| {
                *i += T::one();
                *j += U::one();
            });
        self
    }
    fn dec(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j, _)| {
                *i -= T::one();
                *j -= U::one();
            });
        self
    }
}
impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V, W> IncDec
for Vec<(T, U, V, W)> {
    fn inc(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j, ..)| {
                *i += T::one();
                *j += U::one();
            });
        self
    }
    fn dec(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j, ..)| {
                *i -= T::one();
                *j -= U::one();
            });
        self
    }
}
impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One, V, W, X> IncDec
for Vec<(T, U, V, W, X)> {
    fn inc(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j, ..)| {
                *i += T::one();
                *j += U::one();
            });
        self
    }
    fn dec(mut self) -> Self {
        self.iter_mut()
            .for_each(|(i, j, ..)| {
                *i -= T::one();
                *j -= U::one();
            });
        self
    }
}
impl<T: AdditionMonoidWithSub + One, U: AdditionMonoidWithSub + One> IncDec for (T, U) {
    fn inc(mut self) -> Self {
        self.0 += T::one();
        self.1 += U::one();
        self
    }
    fn dec(mut self) -> Self {
        self.0 -= T::one();
        self.1 -= U::one();
        self
    }
}
}
}
}
pub mod io {
pub mod input {
use crate::algo_lib::collections::vec_ext::default::default_vec;
use std::io::Read;
use std::mem::MaybeUninit;
pub struct Input<'s> {
    input: &'s mut (dyn Read + Send),
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
    eol: bool,
}
macro_rules! read_impl {
    ($t:ty, $read_name:ident, $read_vec_name:ident) => {
        pub fn $read_name (& mut self) -> $t { self.read() } pub fn $read_vec_name (& mut
        self, len : usize) -> Vec <$t > { self.read_vec(len) }
    };
    ($t:ty, $read_name:ident, $read_vec_name:ident, $read_pair_vec_name:ident) => {
        read_impl!($t, $read_name, $read_vec_name); pub fn $read_pair_vec_name (& mut
        self, len : usize) -> Vec < ($t, $t) > { self.read_vec(len) }
    };
}
impl<'s> Input<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;
    pub fn new(input: &'s mut (dyn Read + Send)) -> Self {
        Self {
            input,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            buf_read: 0,
            eol: true,
        }
    }
    pub fn new_with_size(input: &'s mut (dyn Read + Send), buf_size: usize) -> Self {
        Self {
            input,
            buf: default_vec(buf_size),
            at: 0,
            buf_read: 0,
            eol: true,
        }
    }
    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            if res == b'\r' {
                self.eol = true;
                if self.refill_buffer() && self.buf[self.at] == b'\n' {
                    self.at += 1;
                }
                return Some(b'\n');
            }
            self.eol = res == b'\n';
            Some(res)
        } else {
            None
        }
    }
    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            Some(if res == b'\r' { b'\n' } else { res })
        } else {
            None
        }
    }
    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !b.is_ascii_whitespace() {
                return;
            }
            self.get();
        }
    }
    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if c.is_ascii_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() { None } else { Some(res) }
    }
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }
    pub fn is_empty(&mut self) -> bool {
        self.skip_whitespace();
        self.is_exhausted()
    }
    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }
    pub fn read_vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0..size {
            res.push(self.read());
        }
        res
    }
    pub fn read_char(&mut self) -> u8 {
        self.skip_whitespace();
        self.get().unwrap()
    }
    read_impl!(u32, read_unsigned, read_unsigned_vec);
    read_impl!(u64, read_u64, read_u64_vec);
    read_impl!(usize, read_size, read_size_vec, read_size_pair_vec);
    read_impl!(i32, read_int, read_int_vec, read_int_pair_vec);
    read_impl!(i64, read_long, read_long_vec, read_long_pair_vec);
    read_impl!(i128, read_i128, read_i128_vec);
    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = self.input.read(&mut self.buf).unwrap();
            self.buf_read != 0
        } else {
            true
        }
    }
    pub fn is_eol(&self) -> bool {
        self.eol
    }
}
pub trait Readable {
    fn read(input: &mut Input) -> Self;
}
impl Readable for u8 {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}
impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.read_vec(size)
    }
}
impl<T: Readable, const SIZE: usize> Readable for [T; SIZE] {
    fn read(input: &mut Input) -> Self {
        unsafe {
            let mut res = MaybeUninit::<[T; SIZE]>::uninit();
            for i in 0..SIZE {
                let ptr: *mut T = (*res.as_mut_ptr()).as_mut_ptr();
                ptr.add(i).write(input.read::<T>());
            }
            res.assume_init()
        }
    }
}
macro_rules! read_integer {
    ($($t:ident)+) => {
        $(impl Readable for $t { fn read(input : & mut Input) -> Self { input
        .skip_whitespace(); let mut c = input.get().unwrap(); let sgn = match c { b'-' =>
        { c = input.get().unwrap(); true } b'+' => { c = input.get().unwrap(); false } _
        => false, }; let mut res = 0; loop { assert!(c.is_ascii_digit()); res *= 10; let
        d = (c - b'0') as $t; if sgn { res -= d; } else { res += d; } match input.get() {
        None => break, Some(ch) => { if ch.is_ascii_whitespace() { break; } else { c =
        ch; } } } } res } })+
    };
}
read_integer!(i8 i16 i32 i64 i128 isize u16 u32 u64 u128 usize);
macro_rules! tuple_readable {
    ($($name:ident)+) => {
        impl <$($name : Readable),+> Readable for ($($name,)+) { fn read(input : & mut
        Input) -> Self { ($($name ::read(input),)+) } }
    };
}
tuple_readable! {
    T
}
tuple_readable! {
    T U
}
tuple_readable! {
    T U V
}
tuple_readable! {
    T U V X
}
tuple_readable! {
    T U V X Y
}
tuple_readable! {
    T U V X Y Z
}
tuple_readable! {
    T U V X Y Z A
}
tuple_readable! {
    T U V X Y Z A B
}
tuple_readable! {
    T U V X Y Z A B C
}
tuple_readable! {
    T U V X Y Z A B C D
}
tuple_readable! {
    T U V X Y Z A B C D E
}
tuple_readable! {
    T U V X Y Z A B C D E F
}
}
pub mod output {
use crate::algo_lib::collections::vec_ext::default::default_vec;
use std::cmp::Reverse;
use std::io::{stderr, Stderr, Write};
#[derive(Copy, Clone)]
pub enum BoolOutput {
    YesNo,
    YesNoCaps,
    PossibleImpossible,
    Custom(&'static str, &'static str),
}
impl BoolOutput {
    pub fn output(&self, output: &mut Output, val: bool) {
        (if val { self.yes() } else { self.no() }).write(output);
    }
    fn yes(&self) -> &str {
        match self {
            BoolOutput::YesNo => "Yes",
            BoolOutput::YesNoCaps => "YES",
            BoolOutput::PossibleImpossible => "Possible",
            BoolOutput::Custom(yes, _) => yes,
        }
    }
    fn no(&self) -> &str {
        match self {
            BoolOutput::YesNo => "No",
            BoolOutput::YesNoCaps => "NO",
            BoolOutput::PossibleImpossible => "Impossible",
            BoolOutput::Custom(_, no) => no,
        }
    }
}
pub struct Output<'s> {
    output: &'s mut dyn Write,
    buf: Vec<u8>,
    at: usize,
    auto_flush: bool,
    bool_output: BoolOutput,
    precision: Option<usize>,
    separator: u8,
}
impl<'s> Output<'s> {
    const DEFAULT_BUF_SIZE: usize = 4096;
    pub fn new(output: &'s mut dyn Write) -> Self {
        Self {
            output,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            auto_flush: false,
            bool_output: BoolOutput::YesNoCaps,
            precision: None,
            separator: b' ',
        }
    }
    pub fn new_with_auto_flush(output: &'s mut dyn Write) -> Self {
        Self {
            output,
            buf: default_vec(Self::DEFAULT_BUF_SIZE),
            at: 0,
            auto_flush: true,
            bool_output: BoolOutput::YesNoCaps,
            precision: None,
            separator: b' ',
        }
    }
    pub fn flush(&mut self) {
        if self.at != 0 {
            self.output.write_all(&self.buf[..self.at]).unwrap();
            self.output.flush().unwrap();
            self.at = 0;
        }
    }
    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
        self.maybe_flush();
    }
    pub fn print_line<T: Writable>(&mut self, s: T) {
        self.print(s);
        self.put(b'\n');
        self.maybe_flush();
    }
    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }
    pub fn maybe_flush(&mut self) {
        if self.auto_flush {
            self.flush();
        }
    }
    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        self.print_per_line_iter(arg.iter());
    }
    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(self.separator);
            }
            e.write(self);
        }
    }
    pub fn print_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        self.print_iter(iter);
        self.put(b'\n');
    }
    pub fn print_per_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        for e in iter {
            e.write(self);
            self.put(b'\n');
        }
    }
    pub fn set_bool_output(&mut self, bool_output: BoolOutput) {
        self.bool_output = bool_output;
    }
    pub fn set_precision(&mut self, precision: usize) {
        self.precision = Some(precision);
    }
    pub fn reset_precision(&mut self) {
        self.precision = None;
    }
    pub fn get_precision(&self) -> Option<usize> {
        self.precision
    }
    pub fn separator(&self) -> u8 {
        self.separator
    }
    pub fn set_separator(&mut self, separator: u8) {
        self.separator = separator;
    }
}
impl Write for Output<'_> {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        self.maybe_flush();
        Ok(buf.len())
    }
    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}
pub trait Writable {
    fn write(&self, output: &mut Output);
}
impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}
impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}
impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}
impl Writable for u8 {
    fn write(&self, output: &mut Output) {
        output.put(*self);
    }
}
impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter(self.iter());
    }
}
impl<T: Writable, const N: usize> Writable for [T; N] {
    fn write(&self, output: &mut Output) {
        output.print_iter(self.iter());
    }
}
impl<T: Writable + ?Sized> Writable for &T {
    fn write(&self, output: &mut Output) {
        T::write(self, output)
    }
}
impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self.as_slice().write(output);
    }
}
impl Writable for () {
    fn write(&self, _output: &mut Output) {}
}
macro_rules! write_to_string {
    ($($t:ident)+) => {
        $(impl Writable for $t { fn write(& self, output : & mut Output) { self
        .to_string().write(output); } })+
    };
}
write_to_string!(u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
macro_rules! tuple_writable {
    ($name0:ident $($name:ident : $id:tt)*) => {
        impl <$name0 : Writable, $($name : Writable,)*> Writable for ($name0, $($name,)*)
        { fn write(& self, out : & mut Output) { self.0.write(out); $(out.put(out
        .separator); self.$id .write(out);)* } }
    };
}
tuple_writable! {
    T
}
tuple_writable! {
    T U : 1
}
tuple_writable! {
    T U : 1 V : 2
}
tuple_writable! {
    T U : 1 V : 2 X : 3
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5 A : 6
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5 A : 6 B : 7
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5 A : 6 B : 7 C : 8
}
impl<T: Writable> Writable for Option<T> {
    fn write(&self, output: &mut Output) {
        match self {
            None => (-1).write(output),
            Some(t) => t.write(output),
        }
    }
}
impl Writable for bool {
    fn write(&self, output: &mut Output) {
        let bool_output = output.bool_output;
        bool_output.output(output, *self)
    }
}
impl<T: Writable> Writable for Reverse<T> {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
    }
}
static mut ERR: Option<Stderr> = None;
pub fn err() -> Output<'static> {
    unsafe {
        if ERR.is_none() {
            ERR = Some(stderr());
        }
        Output::new_with_auto_flush(ERR.as_mut().unwrap())
    }
}
}
}
pub mod misc {
pub mod test_type {
pub enum TestType {
    Single,
    MultiNumber,
    MultiEof,
}
pub enum TaskType {
    Classic,
    Interactive,
}
}
}
pub mod numbers {
pub mod num_traits {
pub mod algebra {
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
use std::ops::{
    Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign,
};
pub trait Zero {
    fn zero() -> Self;
}
pub trait One {
    fn one() -> Self;
}
pub trait AdditionMonoid: Add<Output = Self> + AddAssign + Zero + Eq + Sized {}
impl<T: Add<Output = Self> + AddAssign + Zero + Eq> AdditionMonoid for T {}
pub trait AdditionMonoidWithSub: AdditionMonoid + Sub<Output = Self> + SubAssign {}
impl<T: AdditionMonoid + Sub<Output = Self> + SubAssign> AdditionMonoidWithSub for T {}
pub trait AdditionGroup: AdditionMonoidWithSub + Neg<Output = Self> {}
impl<T: AdditionMonoidWithSub + Neg<Output = Self>> AdditionGroup for T {}
pub trait MultiplicationMonoid: Mul<Output = Self> + MulAssign + One + Eq + Sized {}
impl<T: Mul<Output = Self> + MulAssign + One + Eq> MultiplicationMonoid for T {}
pub trait IntegerMultiplicationMonoid: MultiplicationMonoid + Div<
        Output = Self,
    > + Rem<Output = Self> + DivAssign + RemAssign {}
impl<
    T: MultiplicationMonoid + Div<Output = Self> + Rem<Output = Self> + DivAssign
        + RemAssign,
> IntegerMultiplicationMonoid for T {}
pub trait MultiplicationGroup: MultiplicationMonoid + Div<
        Output = Self,
    > + DivAssign + Invertible<Output = Self> {}
impl<
    T: MultiplicationMonoid + Div<Output = Self> + DivAssign + Invertible<Output = Self>,
> MultiplicationGroup for T {}
pub trait SemiRing: AdditionMonoid + MultiplicationMonoid {}
impl<T: AdditionMonoid + MultiplicationMonoid> SemiRing for T {}
pub trait SemiRingWithSub: AdditionMonoidWithSub + SemiRing {}
impl<T: AdditionMonoidWithSub + SemiRing> SemiRingWithSub for T {}
pub trait Ring: SemiRing + AdditionGroup {}
impl<T: SemiRing + AdditionGroup> Ring for T {}
pub trait IntegerSemiRing: SemiRing + IntegerMultiplicationMonoid {}
impl<T: SemiRing + IntegerMultiplicationMonoid> IntegerSemiRing for T {}
pub trait IntegerSemiRingWithSub: SemiRingWithSub + IntegerSemiRing {}
impl<T: SemiRingWithSub + IntegerSemiRing> IntegerSemiRingWithSub for T {}
pub trait IntegerRing: IntegerSemiRing + Ring {}
impl<T: IntegerSemiRing + Ring> IntegerRing for T {}
pub trait Field: Ring + MultiplicationGroup {}
impl<T: Ring + MultiplicationGroup> Field for T {}
macro_rules! zero_one_integer_impl {
    ($($t:ident)+) => {
        $(impl Zero for $t { fn zero() -> Self { 0 } } impl One for $t { fn one() -> Self
        { 1 } })+
    };
}
zero_one_integer_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize);
}
pub mod invertible {
pub trait Invertible {
    type Output;
    fn inv(&self) -> Option<Self::Output>;
}
}
}
}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 2284kb

input:

3
3 5 2
1 4 13 6 8 11 14 2 7 10 3 15 9 5 12
2 3 0
1 6 4 3 5 2
2 3 1000000000
1 2 3 4 5 6

output:

7
5
3

result:

ok 3 number(s): "7 5 3"

Test #2:

score: 0
Accepted
time: 2ms
memory: 2232kb

input:

10000
1 9 7
8 9 1 5 3 7 4 6 2
1 8 2
7 5 1 6 4 2 3 8
1 1 0
1
1 8 3
5 7 8 3 2 1 4 6
1 10 948645336
3 10 1 6 2 8 9 5 7 4
1 1 0
1
1 10 7
5 3 10 8 1 7 4 9 6 2
1 9 6
4 8 5 7 2 6 3 1 9
1 7 1
3 5 1 6 2 7 4
1 6 6
5 3 1 2 4 6
1 1 1
1
1 2 0
1 2
1 1 1
1
1 6 3
5 6 2 4 3 1
1 5 673454194
2 3 1 4 5
1 4 1
1 4 2 3
1 ...

output:

9
8
1
8
10
1
10
9
7
6
1
2
1
6
5
4
1
7
3
3
6
8
9
10
5
6
2
10
4
2
5
7
10
1
4
1
3
9
1
2
4
3
10
5
5
2
5
6
9
5
10
1
7
5
2
2
7
1
2
9
8
9
1
6
6
2
2
1
2
6
4
6
1
2
6
4
2
3
4
7
3
4
1
6
3
5
10
7
4
1
10
3
4
2
6
10
1
8
4
9
9
10
4
6
3
3
6
2
2
6
6
10
7
7
1
3
2
7
9
3
4
4
5
6
3
7
5
6
5
5
8
2
6
6
9
7
7
10
8
1
1
10
7
...

result:

ok 10000 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 2084kb

input:

1000
6 9 7
38 29 47 30 9 34 4 33 6 15 35 13 41 14 25 37 8 43 52 16 23 39 32 21 36 28 27 17 20 50 11 12 10 5 42 46 45 3 2 1 49 19 40 18 22 53 24 26 54 51 44 31 7 48
9 10 0
16 68 8 22 9 49 87 24 3 81 23 75 31 84 40 62 63 83 29 71 39 56 69 7 66 79 26 42 64 27 17 54 18 65 21 10 82 25 36 1 12 57 41 37 47...

output:

9
76
6
3
4
5
34
9
3
4
2
24
1
9
11
30
9
2
2
8
5
69
7
7
7
2
12
42
21
8
5
1
7
4
8
9
48
3
4
1
4
5
4
7
3
9
7
1
10
15
3
7
25
8
1
7
4
1
1
7
10
5
8
15
7
8
3
20
9
27
23
9
8
3
9
7
1
1
1
6
16
5
9
1
2
3
3
17
35
3
31
5
1
18
10
5
1
2
1
35
4
4
3
10
12
2
2
3
7
10
7
7
44
6
13
4
6
23
47
7
22
10
7
23
7
2
7
8
46
7
9
1
...

result:

ok 1000 numbers

Test #4:

score: 0
Accepted
time: 1ms
memory: 2232kb

input:

10
95 96 140424908
5498 6378 2916 4539 8803 3415 4563 4328 1173 7196 1631 8768 4510 1149 5261 1243 9023 4557 9005 3261 6239 4575 3386 7990 8679 8296 205 7807 8115 1802 1226 7774 5646 363 6461 7941 3470 5282 5621 5223 5492 7931 5821 5182 4388 3489 2681 6481 8871 2112 2630 733 2579 5741 1157 5556 6944...

output:

96
97
4570
1166
585
2327
893
89
5395
3171

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 2692kb

input:

1
1 100000 50000
50735 33590 8670 95305 15643 46124 46825 30396 43426 34338 25755 40318 20155 23825 54910 95081 43646 93083 89153 93056 66677 70986 20967 73894 58116 87202 55261 19069 68782 79512 68744 16648 10038 45316 28100 22845 91291 85929 50817 37608 24935 32949 3173 8506 17477 90158 49110 7393...

output:

100000

result:

ok 1 number(s): "100000"

Test #6:

score: 0
Accepted
time: 3ms
memory: 2696kb

input:

1
2 50000 10000
99395 38827 46503 21511 80654 44941 94835 85732 12756 99227 29262 89683 27147 51454 92147 52372 66446 45221 63290 5514 32463 19306 91908 78125 34345 37356 8873 18063 41335 22427 61202 36545 9687 90263 64732 91469 23887 89327 13507 14088 67610 68970 39355 79387 24686 44139 41710 28085...

output:

79940

result:

ok 1 number(s): "79940"

Test #7:

score: 0
Accepted
time: 0ms
memory: 2808kb

input:

1
10 10000 1000
7841 86148 35458 22053 72597 99955 66349 84430 13043 68103 50209 12941 29493 50205 68003 37387 19345 30042 88593 95421 85892 8176 64998 83812 64897 912 78966 51597 79612 35547 45504 92981 55903 54384 39524 70719 27882 23983 8478 91178 11709 33200 76036 99034 85575 50663 22612 62437 3...

output:

89637

result:

ok 1 number(s): "89637"

Test #8:

score: 0
Accepted
time: 3ms
memory: 2700kb

input:

1
100 1000 100
79514 31836 98006 66865 91658 11319 83663 44332 91597 86333 59662 47403 21514 40328 58367 27170 42943 36169 78438 6434 99511 64881 18574 74072 34877 58898 17335 67237 82479 2561 30015 84884 36641 30355 62680 20120 6606 35328 93524 36869 32590 66124 5543 48840 47093 43584 83778 40201 7...

output:

87546

result:

ok 1 number(s): "87546"

Test #9:

score: 0
Accepted
time: 3ms
memory: 2724kb

input:

1
316 316 20
50379 4273 79924 69076 22163 18129 4652 41333 34378 92415 75437 11838 89914 18079 15463 43828 27187 64638 52368 65514 14222 576 55468 9095 91827 98298 46509 41708 88632 72017 29994 73817 78812 33371 23835 32549 76291 2361 65209 59502 51374 97277 31561 38137 49463 98279 2910 42477 2178 7...

output:

87823

result:

ok 1 number(s): "87823"

Test #10:

score: 0
Accepted
time: 0ms
memory: 2700kb

input:

1
1000 100 10
28219 36888 7060 88192 67345 8034 80465 69104 69828 65821 2379 4546 50742 44741 49155 19246 82313 10065 20443 24843 58536 74667 86276 10742 86582 84761 88633 49487 76085 26409 57664 66506 35257 58687 72087 54239 34046 10487 33411 41508 59565 55243 18457 3756 68701 47813 8197 10767 6190...

output:

76758

result:

ok 1 number(s): "76758"

Test #11:

score: 0
Accepted
time: 2ms
memory: 2752kb

input:

1
10000 10 2
63649 14562 779 31060 84730 3390 1402 70955 27426 79066 4156 82101 95994 42943 67415 9064 24177 88533 78946 40125 47217 68506 98024 89760 73146 71691 99738 24048 47688 82209 48668 79705 79917 27610 93536 82477 57841 1489 93362 52547 57545 93218 2251 20688 29636 88100 94802 20862 43091 6...

output:

22087

result:

ok 1 number(s): "22087"

Test #12:

score: 0
Accepted
time: 2ms
memory: 2844kb

input:

1
50000 2 1
73762 12124 29167 93932 27022 2261 98803 12289 28686 35629 6478 52631 50403 99767 73864 44612 71726 23092 50842 16335 2826 42247 28898 50690 55343 14055 17481 93427 58724 62628 93041 25561 38703 88920 6409 69902 4451 33782 42523 60018 51816 26451 228 62568 50789 4886 59807 52694 31135 58...

output:

2

result:

ok 1 number(s): "2"

Test #13:

score: 0
Accepted
time: 2ms
memory: 2828kb

input:

1
100000 1 0
47746 9112 49327 145 41482 40565 38394 27153 14733 61278 93184 54590 79706 40614 62572 35720 521 45061 42716 62906 93088 30544 31984 70643 57485 50078 98609 39793 84781 37550 94424 64614 85388 97773 16810 41861 28035 61274 29756 78534 96771 18831 84715 60118 69489 92929 52968 38622 9075...

output:

1

result:

ok 1 number(s): "1"

Extra Test:

score: 0
Extra Test Passed