Submission #6160796
Source Code Expand
Copy
//! ----------------------------------------------//! Framework <https://github.com/vain0x/procon>//!//! See the bottom of file for solution.//! ----------------------------------------------#![allow(unused_imports)]#![allow(non_snake_case)]use std::cell::RefCell;use std::cmp::{max, min, Ordering};use std::collections::*;use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};use std::io::{stderr, stdin, BufRead, Write};use std::mem::{replace, swap};use std::ops::*;use std::rc::Rc;/// Print values to standard error if debug mode.#[allow(unused_macros)]macro_rules! debug {
//! ---------------------------------------------- //! Framework <https://github.com/vain0x/procon> //! //! See the bottom of file for solution. //! ---------------------------------------------- #![allow(unused_imports)] #![allow(non_snake_case)] use std::cell::RefCell; use std::cmp::{max, min, Ordering}; use std::collections::*; use std::fmt::{Debug, Display, Formatter, Write as FmtWrite}; use std::io::{stderr, stdin, BufRead, Write}; use std::mem::{replace, swap}; use std::ops::*; use std::rc::Rc; /// Print values to standard error if debug mode. #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), stderr()); writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap() })* }; } /// Read from standard input and parse each word. /// - `read!(T, U, ..)` parses a line as a tuple of words. /// - `read![[T]]` parses a line as an array of words. /// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly. #[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>()); ($($t:ty),+ ; $n:expr) => ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>()); ([$t:ty]) => (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>()); ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } /// Read a line from standard input. #[allow(dead_code)] fn rl() -> String { let mut buf = String::new(); stdin().read_line(&mut buf).unwrap(); #[allow(deprecated)] buf.trim_right().to_owned() } // ----------------------------------------------- // Solution // ----------------------------------------------- fn main() { let N = read!(usize); let mut d = read![[i64]]; d.sort(); let mut di = 0; let mut abc = 0; let mut arc = N; let mut count = 0; let mut K = 1; while K <= 100000 { if abc == arc { count += 1; } while di < d.len() && d[di] == K { abc += 1; arc -= 1; di += 1; } K += 1; } println!("{}", count) }
Submission Info
Submission Time | |
---|---|
Task | C - Divide the Problems |
User | vain0 |
Language | Rust (1.15.1) |
Score | 300 |
Code Size | 2401 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 6396 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.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, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 2 ms | 4352 KB |
02.txt | AC | 2 ms | 4352 KB |
03.txt | AC | 2 ms | 4352 KB |
04.txt | AC | 2 ms | 4352 KB |
05.txt | AC | 2 ms | 4352 KB |
06.txt | AC | 2 ms | 4352 KB |
07.txt | AC | 2 ms | 4352 KB |
08.txt | AC | 2 ms | 4352 KB |
09.txt | AC | 2 ms | 4352 KB |
10.txt | AC | 2 ms | 4352 KB |
11.txt | AC | 2 ms | 4352 KB |
12.txt | AC | 2 ms | 4352 KB |
13.txt | AC | 10 ms | 6396 KB |
14.txt | AC | 4 ms | 4352 KB |
15.txt | AC | 7 ms | 4352 KB |
16.txt | AC | 8 ms | 4352 KB |
17.txt | AC | 7 ms | 4352 KB |
18.txt | AC | 7 ms | 4352 KB |
19.txt | AC | 11 ms | 6396 KB |
20.txt | AC | 11 ms | 6396 KB |
21.txt | AC | 13 ms | 4352 KB |
22.txt | AC | 13 ms | 4352 KB |
23.txt | AC | 13 ms | 4352 KB |
24.txt | AC | 13 ms | 4352 KB |
25.txt | AC | 13 ms | 4352 KB |
26.txt | AC | 13 ms | 4352 KB |
27.txt | AC | 13 ms | 4352 KB |
28.txt | AC | 13 ms | 4352 KB |
29.txt | AC | 11 ms | 6396 KB |
30.txt | AC | 7 ms | 6396 KB |
31.txt | AC | 7 ms | 6396 KB |
s1.txt | AC | 2 ms | 4352 KB |
s2.txt | AC | 2 ms | 4352 KB |
s3.txt | AC | 2 ms | 4352 KB |