Submission #1194577
Source Code Expand
use std::io::{self, Stdin}; use std::str::{self, FromStr}; use std::error::Error; fn exec() { let mut sc = Scanner::new(); let n: usize = sc.ne(); let mut a: Vec<i64> = (0..3 * n).map(|_| sc.ne()).collect(); a.sort(); let mut sum = 0; for i in 0..n { sum += a[n + i * 2]; } println!("{}", sum); } fn main() { const STACK: usize = 16 * 1024 * 1024; let _ = std::thread::Builder::new() .stack_size(STACK) .spawn(|| { exec(); }) .unwrap() .join() .unwrap(); } #[allow(dead_code)] struct Scanner { stdin: Stdin, id: usize, buf: Vec<u8>, } #[allow(dead_code)] impl Scanner { fn new() -> Scanner { Scanner { stdin: io::stdin(), id: 0, buf: Vec::new(), } } fn next_line(&mut self) -> Option<String> { let mut res = String::new(); match self.stdin.read_line(&mut res) { Ok(0) => None, Ok(_) => Some(res), Err(why) => panic!("error in read_line: {}", why.description()), } } fn next<T: FromStr>(&mut self) -> Option<T> { while self.buf.len() == 0 { self.buf = match self.next_line() { Some(r) => { self.id = 0; r.trim().as_bytes().to_owned() } None => return None, }; } let l = self.id; assert!(self.buf[l] != b' '); let n = self.buf.len(); let mut r = l; while r < n && self.buf[r] != b' ' { r += 1; } let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() { Ok(s) => Some(s), Err(_) => { panic!("parse error, {:?}", String::from_utf8(self.buf[l..r].to_owned())) } }; while r < n && self.buf[r] == b' ' { r += 1; } if r == n { self.buf.clear(); } else { self.id = r; } res } fn ne<T: FromStr>(&mut self) -> T { self.next::<T>().unwrap() } }
Submission Info
Submission Time | |
---|---|
Task | A - AtCoder Group Contest |
User | mio_h1917 |
Language | Rust (1.15.1) |
Score | 300 |
Code Size | 2260 Byte |
Status | AC |
Exec Time | 38 ms |
Memory | 17656 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt |
All | 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 3 ms | 8572 KB |
00_example_02.txt | AC | 3 ms | 8572 KB |
01.txt | AC | 3 ms | 8572 KB |
02.txt | AC | 3 ms | 8572 KB |
03.txt | AC | 3 ms | 8572 KB |
04.txt | AC | 3 ms | 8572 KB |
05.txt | AC | 5 ms | 8572 KB |
06.txt | AC | 23 ms | 17656 KB |
07.txt | AC | 10 ms | 14588 KB |
08.txt | AC | 38 ms | 16760 KB |
09.txt | AC | 38 ms | 16760 KB |
10.txt | AC | 38 ms | 16760 KB |