結果

問題 No.610 区間賞(Section Award)
ユーザー cympfhcympfh
提出日時 2017-12-18 02:56:51
言語 Rust
(1.77.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 1,993 bytes
コンパイル時間 14,304 ms
コンパイル使用メモリ 401,840 KB
実行使用メモリ 12,388 KB
最終ジャッジ日時 2024-05-09 11:16:31
合計ジャッジ時間 18,292 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 26 ms
11,892 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 18 ms
8,196 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 8 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 13 ms
6,500 KB
testcase_27 AC 26 ms
11,824 KB
testcase_28 AC 24 ms
11,204 KB
testcase_29 AC 17 ms
7,592 KB
testcase_30 AC 22 ms
10,256 KB
testcase_31 AC 12 ms
6,360 KB
testcase_32 AC 25 ms
11,616 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 26 ms
11,600 KB
testcase_35 AC 12 ms
6,752 KB
testcase_36 AC 26 ms
11,772 KB
testcase_37 AC 22 ms
10,524 KB
testcase_38 AC 7 ms
5,376 KB
testcase_39 AC 28 ms
12,260 KB
testcase_40 AC 27 ms
12,388 KB
testcase_41 AC 27 ms
12,388 KB
testcase_42 AC 27 ms
12,260 KB
testcase_43 AC 28 ms
12,388 KB
testcase_44 AC 134 ms
10,456 KB
testcase_45 AC 159 ms
11,596 KB
testcase_46 AC 162 ms
11,672 KB
testcase_47 AC 23 ms
10,536 KB
testcase_48 AC 21 ms
10,356 KB
testcase_49 AC 22 ms
10,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: constant `M` is never used
  --> src/main.rs:26:7
   |
26 | const M: usize = 1_000_000_007;
   |       ^
   |
   = note: `#[warn(dead_code)]` on by default

ソースコード

diff #

#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => { trace!(($($args),*)) }
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.cin();

    let mut a = vec![0; n];
    let mut a_inv = vec![0; n + 1];
    for i in 0..n {
        a[i] = sc.cin();
        a_inv[a[i]] = i + 1;
    }

    let mut b = vec![0; n];
    let mut b_norm = vec![0; n]; // when a=[1,2,3,..,n]
    for i in 0..n {
        b[i] = sc.cin();
        b_norm[i] = a_inv[b[i]];
    }

    let mut cands = vec![];
    let mut max = 0;
    for i in 0..n {
        if max < b_norm[i] {
            cands.push( b[i] );
            max = b_norm[i];
        }
    }

    cands.sort();
    for c in cands { put!(c); }
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}
0