about summary refs log tree commit diff
path: root/codechef/maxfun.rs
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/maxfun.rs')
-rw-r--r--codechef/maxfun.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/codechef/maxfun.rs b/codechef/maxfun.rs
new file mode 100644
index 0000000..444284b
--- /dev/null
+++ b/codechef/maxfun.rs
@@ -0,0 +1,13 @@
+use std::io::BufRead;
+
+fn main() {
+    let stdin = std::io::stdin();
+    let mut lines = stdin.lock().lines();
+    for _t in 0..lines.next().unwrap().unwrap().trim().parse::<u8>().unwrap() {
+        let _n = lines.next().unwrap().unwrap();
+        let line = lines.next().unwrap().unwrap();
+        let i = line.split(' ').map(|x| x.trim().parse().unwrap());
+        let a: Vec<i64> = i.collect();
+        println!("{}", (a.iter().max().unwrap() - a.iter().min().unwrap()) * 2);
+    }
+}