Submission #1092027


Source Code Expand

use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut cnt = 0;
    for _ in 0..n {
        let x: i64 = sc.ne();
        if x & 1 == 1 {
            cnt += 1;
        }
    }
    println!("{}",
             match cnt & 1 {
                 1 => "NO",
                 _ => "YES",
             });
}
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

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) => return 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"),
        };
        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 - Addition
User mio_h1917
Language Rust (1.15.1)
Score 300
Code Size 1975 Byte
Status AC
Exec Time 10 ms
Memory 2300 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 14
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in10.txt, in11.txt, in12.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt
Case Name Status Exec Time Memory
in1.txt AC 10 ms 2300 KB
in10.txt AC 10 ms 2300 KB
in11.txt AC 2 ms 380 KB
in12.txt AC 2 ms 380 KB
in2.txt AC 10 ms 2300 KB
in3.txt AC 10 ms 2300 KB
in4.txt AC 10 ms 2300 KB
in5.txt AC 10 ms 2300 KB
in6.txt AC 10 ms 2300 KB
in7.txt AC 10 ms 2300 KB
in8.txt AC 10 ms 2300 KB
in9.txt AC 10 ms 2300 KB
sample1.txt AC 3 ms 380 KB
sample2.txt AC 2 ms 380 KB