Submission #1870861
Source Code Expand
#[allow(unused_imports)] use std::cmp::{max, min, Ordering}; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::iter::FromIterator; #[allow(unused_imports)] use std::io::stdin; mod util { use std::io::stdin; use std::str::FromStr; use std::fmt::Debug; #[allow(dead_code)] pub fn line() -> String { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().to_string() } #[allow(dead_code)] pub fn gets<T: FromStr>() -> Vec<T> where <T as FromStr>::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse().unwrap()) .collect() } } #[allow(unused_macros)] macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::<Vec<_>>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::<Vec<_>>() }; ($t:ty ;;) => { { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::<Vec<_>>() } }; } #[allow(unused_macros)] macro_rules! debug { ($($a:expr),*) => { println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*); } } fn main() { let n = get!(usize); let mut aa = util::gets::<u64>(); aa.sort(); let mut t = 0; let mut sum = 0; for i in 0..n { if aa[i] > sum * 2 { t = i; } sum += aa[i]; } println!("{}", n - t); }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Creatures |
User | hatoo |
Language | Rust (1.15.1) |
Score | 400 |
Code Size | 2441 Byte |
Status | AC |
Exec Time | 16 ms |
Memory | 8444 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | 16 ms | 6396 KB |
in10.txt | AC | 6 ms | 4352 KB |
in11.txt | AC | 15 ms | 6396 KB |
in12.txt | AC | 13 ms | 8444 KB |
in13.txt | AC | 14 ms | 8444 KB |
in2.txt | AC | 16 ms | 6396 KB |
in3.txt | AC | 16 ms | 6396 KB |
in4.txt | AC | 16 ms | 6396 KB |
in5.txt | AC | 7 ms | 4352 KB |
in6.txt | AC | 13 ms | 6396 KB |
in7.txt | AC | 16 ms | 6396 KB |
in8.txt | AC | 13 ms | 6396 KB |
in9.txt | AC | 3 ms | 4352 KB |
sample1.txt | AC | 2 ms | 4352 KB |
sample2.txt | AC | 2 ms | 4352 KB |
sample3.txt | AC | 2 ms | 4352 KB |