Submission #36684961


Source Code Expand

// -*- coding:utf-8-unix -*-

#![allow(unused_imports)]
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout, stderr};
use std::collections::*;
use proconio::{input, marker::{Bytes, Chars, Isize1, Usize1}, source::{auto::AutoSource, line::LineSource, once::OnceSource}};
use bitset_fixed::BitSet;
use itertools::*;
use num::integer::*;
use petgraph::algo::*;
use petgraph::graph::{DiGraph, Graph, NodeIndex, UnGraph};
use petgraph::unionfind::UnionFind;
use petgraph::visit::{Bfs, Dfs, EdgeRef, NodeCount, NodeIndexable, IntoEdges, Visitable, VisitMap};
use rand::{distributions::WeightedIndex, rngs::ThreadRng, seq::SliceRandom, Rng};
use regex::Regex;
use superslice::Ext;

fn main() {
    //let out = stdout();
    //let mut out = BufWriter::new(out.lock());
    //let err = stderr();
    //let mut err = BufWriter::new(err.lock());
    //let mut source = LineSource::new(BufReader::new(stdin()));
    /*
    input! {
        //from &mut source,
        n: usize,
        mut a: [u32; n],  // Vec<u32>
    }
    */
    let ibuf = getibuf();
    let mut it = ibuf.iter().cloned();
    let (n, l) = (it.parse_u32(), it.parse_u32());

    let l1 = l - 1;
    let mut space = 0;
    let mut f = true;

    for _ in 0..n {
        let ai = it.parse_u32();
        if space < l1 {
            space += ai + 1;
        } else if ai > 1 {
            f = false;
            break;
        }
    }

    let mut out = stdout();
    if f {
        out.write_all(b"Yes\n").unwrap();
    } else {
        out.write_all(b"No\n").unwrap();
    }
    //writeln!(&mut out, "{}", count).unwrap();
    //writeln!(&mut err, "{}", count).unwrap();
    //out.flush().unwrap();
    //err.flush().unwrap();
}

trait Change { fn chmax(&mut self, x: Self); fn chmin(&mut self, x: Self); }
impl<T: PartialOrd> Change for T {
    fn chmax(&mut self, x: T) { if *self < x { *self = x; } }
    fn chmin(&mut self, x: T) { if *self > x { *self = x; } }
}
/** get bytes from stdin */
fn getibuf() -> Vec<u8> {
    use std::io::Read;
    let stdin = std::io::stdin();
    let mut handle = stdin.lock();
    let mut ibuf = vec![];
    handle.read_to_end(&mut ibuf).unwrap();
    ibuf
}
/** input parser for program compete */
trait ProconParse {
    /** parse u32 value */
    fn parse_u32(&mut self) -> u32;
    /** parse u64 value */
    fn parse_u64(&mut self) -> u64;
    /** parse i32 value */
    fn parse_i32(&mut self) -> i32;
    /** parse i64 value */
    fn parse_i64(&mut self) -> i64;
    /** parse char (printable char) */
    fn parse_char(&mut self) -> char;
    /** parse chars (printable word) */
    fn parse_chars(&mut self) -> Vec<char>;
    /** parse String (printable word) */
    fn parse_string(&mut self) -> String { self.parse_chars().iter().collect() }
    /** get line chars (sp+printable ascii) */
    fn get_line_chars(&mut self) -> Vec<char>;
    /** get line String (sp+printable ascii) */
    fn get_line_string(&mut self) -> String { self.get_line_chars().iter().collect() }
    /** get line chars (trimed sp+printable ascii) */
    fn get_line_chars_trim(&mut self) -> Vec<char>;
    /** get line String (trimed sp+printable ascii) */
    fn get_line_string_trim(&mut self) -> String { self.get_line_chars_trim().iter().collect() }
    /** parse u32 (1 => 0-indexed) value */
    fn parse_u32_1(&mut self) -> u32 { self.parse_u32() - 1 }
    /** parse u64 (1 => 0-indexed) value */
    fn parse_u64_1(&mut self) -> u64 { self.parse_u64() - 1 }
    /** parse usize (32bit) value */
    fn parse_usize32(&mut self) -> usize { self.parse_u32() as usize }
    /** parse usize (1 => 0-indexed, 32bit) value */
    fn parse_usize32_1(&mut self) -> usize { self.parse_u32_1() as usize }
    /** parse usize (64bit) value */
    fn parse_usize64(&mut self) -> usize { self.parse_u64() as usize }
    /** parse usize (1 => 0-indexed, 64bit) value */
    fn parse_usize64_1(&mut self) -> usize { self.parse_u64_1() as usize }
}
impl<T: Iterator<Item = u8>> ProconParse for T {
    fn parse_u32(&mut self) -> u32 {
        let mut x = loop { match self.next() {
            Some(c @ b'0'..=b'9') => break (c & 0x0f) as u32,
            Some(_) => {},
            None => unreachable!(),
        }};
        while let Some(c @ b'0'..=b'9') = self.next() { x = x * 10 + (c & 0x0f) as u32; }
        x
    }
    fn parse_u64(&mut self) -> u64 {
        let mut x = loop { match self.next() {
            Some(c @ b'0'..=b'9') => break (c & 0x0f) as u64,
            Some(_) => {},
            None => unreachable!(),
        }};
        while let Some(c @ b'0'..=b'9') = self.next() { x = x * 10 + (c & 0x0f) as u64; }
        x
    }
    fn parse_i32(&mut self) -> i32 {
        let (f, mut x) = loop { match self.next() {
            Some(c @ b'0'..=b'9') => break (false, (c & 0x0f) as i32),
            Some(b'-') => break (true, match self.next() {
                Some(c @ b'0'..=b'9') => -((c & 0x0f) as i32),
                _ => unreachable!(),
            }),
            Some(_) => {},
            None => unreachable!(),
        }};
        match f {
            false => while let Some(c @ b'0'..=b'9') = self.next() { x = x * 10 + (c & 0x0f) as i32; },
            true => while let Some(c @ b'0'..=b'9') = self.next() { x = x * 10 - (c & 0x0f) as i32; },
        }
        x
    }
    fn parse_i64(&mut self) -> i64 {
        let (f, mut x) = loop { match self.next() {
            Some(c @ b'0'..=b'9') => break (false, (c & 0x0f) as i64),
            Some(b'-') => break (true, match self.next() {
                Some(c @ b'0'..=b'9') => -((c & 0x0f) as i64),
                _ => unreachable!(),
            }),
            Some(_) => {},
            None => unreachable!(),
        }};
        match f {
            false => while let Some(c @ b'0'..=b'9') = self.next() { x = x * 10 + (c & 0x0f) as i64; },
            true => while let Some(c @ b'0'..=b'9') = self.next() { x = x * 10 - (c & 0x0f) as i64; },
        }
        x
    }
    fn parse_char(&mut self) -> char {
        loop { match self.next() {
            Some(c @ b'!'..=b'~') => { break c as char },
            Some(_) => {},
            None => unreachable!(),
        }}
    }
    fn parse_chars(&mut self) -> Vec<char> {
        let mut v = loop { match self.next() {
            Some(c @ b'!'..=b'~') => break vec![c as char],
            Some(_) => {},
            None => unreachable!(),
        }};
        while let Some(c @ b'!'..=b'~') = self.next() { v.push(c as char); }
        v
    }
    fn get_line_chars(&mut self) -> Vec<char> {
        let mut v = loop { match self.next() {
            Some(c @ b' '..=b'~') => break vec![c as char],
            Some(_) => {},
            None => unreachable!(),
        }};
        while let Some(c @ b' '..=b'~') = self.next() { v.push(c as char); }
        v
    }
    fn get_line_chars_trim(&mut self) -> Vec<char> {
        let mut v = loop { match self.next() {
            Some(c @ b'!'..=b'~') => break vec![c as char],
            Some(_) => {},
            None => unreachable!(),
        }};
        while let Some(c @ b' '..=b'~') = self.next() { v.push(c as char); }
        while !('!'..='~').contains(v.last().unwrap()) { v.pop(); }
        v
    }
}

Submission Info

Submission Time
Task A - Seat Occupation
User mizarjp
Language Rust (1.42.0)
Score 400
Code Size 7220 Byte
Status AC
Exec Time 4 ms
Memory 2412 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 47
Set Name Test Cases
Sample sample1.txt, sample2.txt
All in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in41.txt, in42.txt, in43.txt, in44.txt, in45.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 2 ms 2236 KiB
in10.txt AC 1 ms 2056 KiB
in11.txt AC 1 ms 1936 KiB
in12.txt AC 1 ms 2204 KiB
in13.txt AC 1 ms 2048 KiB
in14.txt AC 4 ms 2068 KiB
in15.txt AC 3 ms 2168 KiB
in16.txt AC 3 ms 2196 KiB
in17.txt AC 2 ms 1852 KiB
in18.txt AC 2 ms 1888 KiB
in19.txt AC 1 ms 2048 KiB
in2.txt AC 2 ms 2328 KiB
in20.txt AC 3 ms 2144 KiB
in21.txt AC 2 ms 2148 KiB
in22.txt AC 2 ms 2140 KiB
in23.txt AC 1 ms 2356 KiB
in24.txt AC 2 ms 2232 KiB
in25.txt AC 3 ms 2112 KiB
in26.txt AC 2 ms 2088 KiB
in27.txt AC 2 ms 2140 KiB
in28.txt AC 2 ms 2288 KiB
in29.txt AC 2 ms 2220 KiB
in3.txt AC 3 ms 2412 KiB
in30.txt AC 2 ms 2328 KiB
in31.txt AC 2 ms 2260 KiB
in32.txt AC 2 ms 2284 KiB
in33.txt AC 2 ms 2112 KiB
in34.txt AC 2 ms 2232 KiB
in35.txt AC 2 ms 2292 KiB
in36.txt AC 1 ms 1824 KiB
in37.txt AC 1 ms 2032 KiB
in38.txt AC 2 ms 1972 KiB
in39.txt AC 1 ms 1976 KiB
in4.txt AC 3 ms 2264 KiB
in40.txt AC 1 ms 2032 KiB
in41.txt AC 1 ms 1964 KiB
in42.txt AC 1 ms 1968 KiB
in43.txt AC 1 ms 1944 KiB
in44.txt AC 2 ms 2072 KiB
in45.txt AC 1 ms 1908 KiB
in5.txt AC 3 ms 2240 KiB
in6.txt AC 2 ms 2284 KiB
in7.txt AC 1 ms 1964 KiB
in8.txt AC 1 ms 1880 KiB
in9.txt AC 1 ms 2068 KiB
sample1.txt AC 1 ms 1960 KiB
sample2.txt AC 1 ms 1956 KiB