結果

問題 No.2559 眩しい数直線
ユーザー neko_the_shadowneko_the_shadow
提出日時 2024-01-26 15:49:31
言語 Rust
(1.77.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 1,283 ms
コンパイル使用メモリ 188,064 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-26 15:49:34
合計ジャッジ時間 2,607 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 10 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `N` should have a snake case name
 --> Main.rs:4:10
  |
4 |     let (N, X) = read();
  |          ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `X` should have a snake case name
 --> Main.rs:4:13
  |
4 |     let (N, X) = read();
  |             ^ help: convert the identifier to snake case (notice the capitalization): `x`

warning: variable `A` should have a snake case name
 --> Main.rs:5:13
  |
5 |     let mut A = vec![];
  |             ^ help: convert the identifier to snake case: `a`

warning: variable `B` should have a snake case name
 --> Main.rs:6:13
  |
6 |     let mut B = vec![];
  |             ^ help: convert the identifier to snake case: `b`

warning: variable `C` should have a snake case name
  --> Main.rs:13:13
   |
13 |     let mut C = vec![];
   |             ^ help: convert the identifier to snake case (notice the capitalization): `c`

warning: 5 warnings emitted

ソースコード

diff #

use std::{cmp::max, io};

fn main() {
    let (N, X) = read();
    let mut A = vec![];
    let mut B = vec![];
    for _ in 0..N {
        let (a, b) = read();
        A.push(a);
        B.push(b);
    }

    let mut C = vec![];
    for j in 1..=X {
        let mut mx = 0;
        for i in 0..N {
            let tmp = if B[i] >= j.abs_diff(A[i]) { B[i] - j.abs_diff(A[i]) } else { 0 };
            mx = max(mx, tmp)
        }
        C.push(mx);
    }
    println!("{}", C.iter().map(|v| v.to_string()).collect::<Vec<_>>().join(" "));
 }

fn read() -> (usize, usize) {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    let tokens = line.split_whitespace().map(|v| v.parse::<_>().unwrap()).collect::<Vec<_>>();
    (tokens[0], tokens[1])
}

0