結果

問題 No.2500 Products in a Range
ユーザー haihamabossuhaihamabossu
提出日時 2023-10-14 00:49:41
言語 Rust
(1.77.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 2,134 bytes
コンパイル時間 4,791 ms
コンパイル使用メモリ 148,888 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 00:49:50
合計ジャッジ時間 8,038 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 8 ms
4,348 KB
testcase_08 AC 17 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 29 ms
4,352 KB
testcase_11 AC 38 ms
4,348 KB
testcase_12 AC 15 ms
4,352 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 28 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 8 ms
4,352 KB
testcase_17 AC 5 ms
4,352 KB
testcase_18 AC 5 ms
4,352 KB
testcase_19 AC 10 ms
4,356 KB
testcase_20 AC 11 ms
4,352 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 13 ms
4,348 KB
testcase_23 AC 13 ms
4,348 KB
testcase_24 AC 12 ms
4,352 KB
testcase_25 AC 56 ms
4,352 KB
testcase_26 AC 54 ms
4,352 KB
testcase_27 AC 69 ms
4,348 KB
testcase_28 AC 9 ms
4,348 KB
testcase_29 AC 2 ms
4,356 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 1 ms
4,352 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 13 ms
4,352 KB
testcase_34 AC 33 ms
4,348 KB
testcase_35 AC 1 ms
4,348 KB
testcase_36 AC 1 ms
4,352 KB
testcase_37 AC 0 ms
4,352 KB
testcase_38 AC 1 ms
4,348 KB
testcase_39 AC 1 ms
4,352 KB
testcase_40 AC 1 ms
4,352 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 1 ms
4,352 KB
testcase_43 AC 1 ms
4,352 KB
testcase_44 AC 6 ms
4,352 KB
testcase_45 AC 1 ms
4,352 KB
testcase_46 AC 4 ms
4,348 KB
testcase_47 AC 54 ms
4,352 KB
testcase_48 AC 1 ms
4,352 KB
testcase_49 AC 1 ms
4,352 KB
testcase_50 AC 5 ms
4,352 KB
testcase_51 AC 6 ms
4,348 KB
testcase_52 AC 10 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 1 ms
4,352 KB
testcase_55 AC 6 ms
4,352 KB
testcase_56 AC 6 ms
4,352 KB
testcase_57 AC 11 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 11 ms
4,348 KB
testcase_60 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

pub mod scanner {

    pub struct Scanner {
        buf: Vec<String>,
    }

    impl Scanner {
        pub fn new() -> Self {
            Self { buf: vec![] }
        }

        pub fn new_from(source: &str) -> Self {
            let source = String::from(source);
            let buf = Self::split(source);
            Self { buf }
        }

        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            loop {
                if let Some(x) = self.buf.pop() {
                    return x.parse().ok().expect("");
                }
                let mut source = String::new();
                std::io::stdin().read_line(&mut source).expect("");
                self.buf = Self::split(source);
            }
        }

        fn split(source: String) -> Vec<String> {
            source
                .split_whitespace()
                .rev()
                .map(String::from)
                .collect::<Vec<_>>()
        }
    }
}

use crate::scanner::Scanner;
use std::io::Write;
fn main() {
    let mut scanner = Scanner::new();
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let t: usize = 1;
    for _ in 0..t {
        solve(&mut scanner, &mut out);
    }
}
fn solve(scanner: &mut Scanner, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let n = scanner.next::<usize>();
    let l = scanner.next::<isize>();
    let r = scanner.next::<isize>();
    let mut a = (0..n).map(|_| scanner.next::<isize>()).collect::<Vec<_>>();
    a.sort();
    let mut ans = 1;
    for i in 0..n - 1 {
        for j in i + 1..n {
            let b = a[i] * a[j];
            if l <= b && b <= r {
                ans = ans.max(2);
            } else {
                continue;
            }
            let mut ok = true;
            {
                let b = a[i] * a[i + 1];
                ok &= l <= b && b <= r;
            }
            {
                let b = a[j - 1] * a[j];
                ok &= l <= b && b <= r;
            }
            if ok {
                ans = ans.max(j - i + 1);
            }
        }
    }
    writeln!(out, "{}", ans).unwrap();
}
0