結果

問題 No.1285 ゴミ捨て
ユーザー Moss_LocalMoss_Local
提出日時 2020-11-13 22:40:59
言語 Rust
(1.77.0 + proconio)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 6,632 bytes
コンパイル時間 14,221 ms
コンパイル使用メモリ 387,276 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-06 14:33:12
合計ジャッジ時間 14,967 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 19 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 8 ms
6,940 KB
testcase_10 AC 17 ms
6,940 KB
testcase_11 AC 15 ms
6,944 KB
testcase_12 AC 11 ms
6,944 KB
testcase_13 AC 11 ms
6,944 KB
testcase_14 AC 18 ms
6,940 KB
testcase_15 AC 13 ms
6,944 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 4 ms
6,940 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 7 ms
6,944 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 20 ms
6,944 KB
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around type
  --> src/main.rs:38:15
   |
38 | fn readi() -> (i64) {
   |               ^   ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
38 - fn readi() -> (i64) {
38 + fn readi() -> i64 {
   |

warning: unnecessary parentheses around assigned value
   --> src/main.rs:212:22
    |
212 |         let mut xx = (*x);
    |                      ^  ^
    |
help: remove these parentheses
    |
212 -         let mut xx = (*x);
212 +         let mut xx = *x;
    |

warning: unused variable: `ma`
   --> src/main.rs:223:13
    |
223 |     let mut ma = INF;
    |             ^^ help: if this is intentional, prefix it with an underscore: `_ma`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
   --> src/main.rs:223:9
    |
223 |     let mut ma = INF;
    |         ----^^
    |         |
    |         help: remove this `mut`
    |
    = note: `#[warn(unused_mut)]` on by default

ソースコード

diff #

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

#![allow(dead_code)]
#![allow(unused_imports)]

use std::cmp;
use std::cmp::Ordering;
use std::collections::*;
use std::convert::*;
use std::convert::{From, Into};
use std::fmt::Debug;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::marker::Copy;
use std::mem::*;
use std::ops::{Add, Mul, Neg, Sub};
use std::str;
use std::vec;
const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
// const MOD: i64 = 998244353;

use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn readi() -> (i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    iter.next().unwrap().parse::<i64>().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}

fn readff() -> (f64, f64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<f64>().unwrap(),
        iter.next().unwrap().parse::<f64>().unwrap(),
    )
}

#[allow(dead_code)]
fn readiii() -> (i64, i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn readcc() -> (char, char) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<char>().unwrap(),
        iter.next().unwrap().parse::<char>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuuu() -> (usize, usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}
/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}
#[derive(PartialEq, Eq, Clone, Debug)]
enum Inf<T> {
    Val(T),
    Inf,
}
impl<T: Ord> Inf<T> {
    #[allow(dead_code)]
    fn val(self) -> Option<T> {
        match self {
            Inf::Val(v) => Some(v),
            _ => None,
        }
    }
}
impl<T: PartialOrd> PartialOrd for Inf<T> {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        match (self, other) {
            (&Inf::Inf, &Inf::Inf) => Some(Ordering::Equal),
            (&Inf::Inf, &Inf::Val(_)) => Some(Ordering::Greater),
            (&Inf::Val(_), &Inf::Inf) => Some(Ordering::Less),
            (&Inf::Val(ref a), &Inf::Val(ref b)) => a.partial_cmp(b),
        }
    }
}
impl<T: Ord> Ord for Inf<T> {
    fn cmp(&self, other: &Self) -> Ordering {
        match (self, other) {
            (&Inf::Inf, &Inf::Inf) => Ordering::Equal,
            (&Inf::Inf, &Inf::Val(_)) => Ordering::Greater,
            (&Inf::Val(_), &Inf::Inf) => Ordering::Less,
            (&Inf::Val(ref a), &Inf::Val(ref b)) => a.cmp(b),
        }
    }
}
#[allow(dead_code)]
/// Calculate length of Longest Increasing Subsequence. O(N log N)
pub fn lis(seq: &[i64]) -> usize {
    let mut dp: Vec<i64> = vec![INF as i64; seq.len() + 1];
    for x in seq.iter() {
        let mut xx = (*x);
        xx -= 1;
        let i = dp.upper_bound(&xx);
        dp[i] = xx;
    }
    dp.lower_bound(&INF)
}

fn solve() {
    let n: usize = read();
    let mut vec = vec![0; n];
    let mut ma = INF;
    for i in 0..n {
        let x: i64 = read();
        vec[i] = x;
    }
    vec.sort();
    vec.reverse();
    let mut cnt = 1 as usize;
    let mut res = 0;
    for i in 0..n - 1 {
        if vec[i] > vec[i + 1] + 1 {
            res = max(res, cnt);
            cnt = 1;
        } else {
            cnt += 1;
        }
        // res += 1;
    }
    res = max(res, cnt);

    println!("{:?}", res);
}

fn main() {
    solve()
}
0