Submission #1851094


Source Code Expand

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[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 = get!(u64; n);

    let mut ans = 0;


    for i in 0..n - 1 {
        if aa[i] % 2 == 1 && aa[i + 1] > 0 {
            aa[i] -= 1;
            aa[i + 1] -= 1;
            ans += 1;
        }
    }

    for &x in &aa {
        ans += x / 2;
    }
    println!("{}", ans);
}

Submission Info

Submission Time
Task B - Simplified mahjong
User hatoo
Language Rust (1.15.1)
Score 400
Code Size 2503 Byte
Status AC
Exec Time 15 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 24
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 15 ms 4352 KB
02.txt AC 15 ms 4352 KB
03.txt AC 15 ms 4352 KB
04.txt AC 14 ms 4352 KB
05.txt AC 14 ms 4352 KB
06.txt AC 14 ms 4352 KB
07.txt AC 15 ms 4352 KB
08.txt AC 15 ms 4352 KB
09.txt AC 15 ms 4352 KB
10.txt AC 15 ms 4352 KB
11.txt AC 12 ms 4352 KB
12.txt AC 15 ms 4352 KB
13.txt AC 14 ms 4352 KB
14.txt AC 14 ms 4352 KB
15.txt AC 12 ms 4352 KB
16.txt AC 15 ms 4352 KB
17.txt AC 15 ms 4352 KB
18.txt AC 2 ms 4352 KB
19.txt AC 2 ms 4352 KB
20.txt AC 2 ms 4352 KB
21.txt AC 2 ms 4352 KB
22.txt AC 2 ms 4352 KB
s1.txt AC 2 ms 4352 KB
s2.txt AC 2 ms 4352 KB