結果

問題 No.808 Kaiten Sushi?
ユーザー koba-e964koba-e964
提出日時 2019-03-23 03:10:26
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 2,730 bytes
コンパイル時間 12,296 ms
コンパイル使用メモリ 379,076 KB
実行使用メモリ 8,236 KB
最終ジャッジ日時 2024-09-19 17:15:52
合計ジャッジ時間 16,123 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 11 ms
6,940 KB
testcase_24 AC 9 ms
6,944 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 36 ms
8,012 KB
testcase_33 AC 16 ms
6,944 KB
testcase_34 AC 18 ms
6,940 KB
testcase_35 AC 25 ms
6,940 KB
testcase_36 AC 17 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 31 ms
7,560 KB
testcase_40 AC 7 ms
6,944 KB
testcase_41 AC 9 ms
6,940 KB
testcase_42 AC 26 ms
6,944 KB
testcase_43 AC 11 ms
6,940 KB
testcase_44 AC 20 ms
6,940 KB
testcase_45 AC 12 ms
6,944 KB
testcase_46 AC 7 ms
6,944 KB
testcase_47 AC 35 ms
8,112 KB
testcase_48 AC 35 ms
8,108 KB
testcase_49 AC 35 ms
8,112 KB
testcase_50 AC 35 ms
8,112 KB
testcase_51 AC 34 ms
8,236 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 1 ms
6,940 KB
testcase_55 AC 1 ms
6,940 KB
testcase_56 AC 1 ms
6,940 KB
testcase_57 AC 11 ms
6,944 KB
testcase_58 AC 19 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `diff`
  --> src/main.rs:88:13
   |
88 |         let diff = if i < mi.1 { if acc[i] > 0 { -1 } else { 0 } } else { 0 };
   |             ^^^^ help: if this is intentional, prefix it with an underscore: `_diff`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
  --> src/main.rs:93:9
   |
93 |     let mut tot = l * (ma.0 - 1) + st[ma.1].0;
   |         ----^^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        l: i64,
        x: [i64; n],
        y: [i64; n],
    }
    let mut st = vec![];
    for i in 0..n {
        st.push((x[i], 1));
        st.push((y[i], -1));
    }
    st.sort();
    let mut acc = vec![0; 2 * n + 1];
    for i in 0..2 * n {
        acc[i + 1] = acc[i] + st[i].1;
    }
    let mut mi = (0, 0);
    for i in 0..2 * n {
        mi = min(mi, (acc[i], i));
    }
    let mut ma = (0, 0);
    for i in 0..2 * n {
        let diff = if i < mi.1 { if acc[i] > 0 { -1 } else { 0 } } else { 0 };
        ma = max(ma, (acc[i] - mi.0, i % (2 * n)));
    }
    //eprintln!("acc = {:?}", acc);
    eprintln!("mi = {:?}, ma = {:?}", mi, ma);
    let mut tot = l * (ma.0 - 1) + st[ma.1].0;
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}
0