結果

問題 No.127 門松もどき
ユーザー koba-e964koba-e964
提出日時 2017-02-07 16:47:39
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,600 bytes
コンパイル時間 4,389 ms
コンパイル使用メモリ 146,668 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 00:45:16
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
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 -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

fn main() {
    let n = get();
    let mut a: Vec<(i32, usize)> = (0 .. n).map(|i| (get(), i)).collect();
    a.sort();
    let mut dp = vec![vec![0; 2]; n];
    for i in 0 .. n {
        for b in 0 .. 2 {
            let mut ma = 1;
            for j in 0 .. i {
                if a[j].0 >= a[i].0 { continue; }
                if (b == 0 && a[j].1 >= a[i].1) ||
                    (b == 1 && a[j].1 <= a[i].1) {
                        continue;
                    }
                ma = max(ma, dp[j][1 - b] + 1);
            }
            dp[i][b] = ma;
        }
    }
    println!("{}", dp.iter().map(|w| max(w[0], w[1])).max().unwrap());
}
0