結果
| 問題 |
No.1285 ゴミ捨て
|
| コンテスト | |
| ユーザー |
Moss_Local
|
| 提出日時 | 2020-11-13 22:37:43 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 6,504 bytes |
| コンパイル時間 | 12,761 ms |
| コンパイル使用メモリ | 387,364 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-22 21:37:02 |
| 合計ジャッジ時間 | 14,206 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 22 |
コンパイルメッセージ
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
ソースコード
// -*- 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 res = 0 as usize;
for i in 0..n - 1 {
if vec[i] > vec[i] + 1 {
break;
}
res += 1;
}
println!("{:?}", res);
}
fn main() {
solve()
}
Moss_Local