Submission #16084114


Source Code Expand

Copy
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    };
    a.sort();
    let s = a
        .iter()
        .scan(0, |acc, a_i| {
            *acc += a_i;
            Some(*acc)
        })
        .collect::<Vec<_>>();
    let mut c = 0;
    let mut a_p = a[0];
    for (i, &a_i) in a.iter().enumerate().skip(1) {
        if a_p * 2 >= a_i {
            a_p += a_i;
        } else {
            a_p = s[i];
            c = i;
        }
    }
    let ans = n - c;
    println!("{}", ans);
}

Submission Info

Submission Time
Task B - Colorful Creatures
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 531 Byte
Status AC
Exec Time 29 ms
Memory 4916 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
in1.txt AC 27 ms 4884 KB
in10.txt AC 18 ms 2932 KB
in11.txt AC 23 ms 4612 KB
in12.txt AC 18 ms 4828 KB
in13.txt AC 17 ms 4916 KB
in2.txt AC 29 ms 4684 KB
in3.txt AC 23 ms 4792 KB
in4.txt AC 23 ms 4852 KB
in5.txt AC 11 ms 3072 KB
in6.txt AC 22 ms 4296 KB
in7.txt AC 24 ms 4784 KB
in8.txt AC 23 ms 4036 KB
in9.txt AC 4 ms 2304 KB
sample1.txt AC 2 ms 2152 KB
sample2.txt AC 2 ms 2024 KB
sample3.txt AC 3 ms 2104 KB