Submission #62531707


Source Code Expand

use itertools::{iproduct, Itertools};
use num_rational::Ratio;
use proconio::input;

fn main() {
    input!{
        n: usize,
    }
    static N: usize = 1e5 as usize+2;
    let mut v = vec![];
    let mut sums = vec![];

    for i in 0..n {
        input! {
            k: usize,
            a: [u64; k],
        }
        let a = a.iter().copied().sorted_unstable().dedup_with_count().collect_vec();
        sums.push(k as f64);
        v.push(a);
    }

    let mut ans :f64 = 0.;
    for i in 0..n {
        for j in i+1..n {
            let mut ii = 0;
            let mut ji = 0;
            let mut sum = 0.;
            while ii < v[i].len() && ji < v[j].len() {
                if v[i][ii].1 == v[j][ji].1 {
                    sum += v[i][ii].0 as f64 / sums[i] * v[j][ji].0 as f64 / sums[j];
                    ii += 1;
                    ji += 1;
                } else if v[i][ii].1 < v[j][ji].1 {
                    ii += 1;
                } else {
                    ji += 1;
                }
            }
            ans = ans.max(sum);
        }
    }
    println!("{}", ans);

}

Submission Info

Submission Time
Task D - Doubles
User ardRiriy
Language Rust (rustc 1.70.0)
Score 400
Code Size 1154 Byte
Status AC
Exec Time 57 ms
Memory 5304 KiB

Compile Error

warning: unused import: `iproduct`
 --> src/main.rs:2:17
  |
2 | use itertools::{iproduct, Itertools};
  |                 ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `num_rational::Ratio`
 --> src/main.rs:3:5
  |
3 | use num_rational::Ratio;
  |     ^^^^^^^^^^^^^^^^^^^

warning: unused variable: `i`
  --> src/main.rs:14:9
   |
14 |     for i in 0..n {
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: static `N` is never used
  --> src/main.rs:10:12
   |
10 |     static N: usize = 1e5 as usize+2;
   |            ^
   |
   = note: `#[warn(dead_code)]` on by default

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 26
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All 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_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 3 ms 3512 KiB
random_02.txt AC 3 ms 2972 KiB
random_03.txt AC 7 ms 4392 KiB
random_04.txt AC 9 ms 4420 KiB
random_05.txt AC 3 ms 3104 KiB
random_06.txt AC 3 ms 2880 KiB
random_07.txt AC 8 ms 4488 KiB
random_08.txt AC 9 ms 4460 KiB
random_09.txt AC 3 ms 3312 KiB
random_10.txt AC 3 ms 3240 KiB
random_11.txt AC 6 ms 4752 KiB
random_12.txt AC 8 ms 4244 KiB
random_13.txt AC 3 ms 3380 KiB
random_14.txt AC 7 ms 4820 KiB
random_15.txt AC 3 ms 4044 KiB
random_16.txt AC 6 ms 5024 KiB
random_17.txt AC 0 ms 1992 KiB
random_18.txt AC 3 ms 2620 KiB
random_19.txt AC 57 ms 4196 KiB
random_20.txt AC 9 ms 4220 KiB
random_21.txt AC 4 ms 5304 KiB
random_22.txt AC 3 ms 3904 KiB
random_23.txt AC 17 ms 4188 KiB
random_24.txt AC 17 ms 4220 KiB
sample_01.txt AC 0 ms 2152 KiB
sample_02.txt AC 0 ms 2096 KiB