結果
問題 | No.1285 ゴミ捨て |
ユーザー | Moss_Local |
提出日時 | 2020-11-13 22:20:41 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,363 bytes |
コンパイル時間 | 18,432 ms |
コンパイル使用メモリ | 382,988 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-22 21:10:18 |
合計ジャッジ時間 | 14,524 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
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 { |
ソースコード
// -*- 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<T: Ord>(seq: &[T]) -> usize { let mut dp: Vec<Inf<&T>> = vec![Inf::Inf; seq.len() + 1]; for x in seq.iter() { let i = dp.upper_bound(&Inf::Val(x)); dp[i] = Inf::Val(x); } dp.lower_bound(&Inf::Inf) } fn solve() { let n: usize = read(); let mut vec = vec![0; n]; for i in 0..n { let x: i64 = read(); vec[i] = x * (-1); } // vec.reverse(); let v = &vec[..]; let l = lis(v); println!("{:?}", l); } fn main() { solve() }