結果

問題 No.1110 好きな歌
ユーザー StrorkisStrorkis
提出日時 2020-07-10 22:00:56
言語 Rust
(1.77.0)
結果
AC  
実行時間 299 ms / 5,000 ms
コード長 997 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 170,984 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 17:08:23
合計ジャッジ時間 9,559 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 0 ms
6,944 KB
testcase_06 AC 0 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 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 1 ms
6,940 KB
testcase_13 AC 0 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 171 ms
6,940 KB
testcase_25 AC 202 ms
6,944 KB
testcase_26 AC 107 ms
6,940 KB
testcase_27 AC 203 ms
6,940 KB
testcase_28 AC 113 ms
6,940 KB
testcase_29 AC 243 ms
6,944 KB
testcase_30 AC 111 ms
6,940 KB
testcase_31 AC 72 ms
6,940 KB
testcase_32 AC 267 ms
6,940 KB
testcase_33 AC 122 ms
6,940 KB
testcase_34 AC 173 ms
6,940 KB
testcase_35 AC 299 ms
6,944 KB
testcase_36 AC 29 ms
6,940 KB
testcase_37 AC 79 ms
6,944 KB
testcase_38 AC 236 ms
6,940 KB
testcase_39 AC 176 ms
6,944 KB
testcase_40 AC 222 ms
6,940 KB
testcase_41 AC 17 ms
6,940 KB
testcase_42 AC 252 ms
6,940 KB
testcase_43 AC 227 ms
6,944 KB
testcase_44 AC 282 ms
6,944 KB
testcase_45 AC 284 ms
6,944 KB
testcase_46 AC 273 ms
6,944 KB
testcase_47 AC 293 ms
6,940 KB
testcase_48 AC 290 ms
6,944 KB
testcase_49 AC 269 ms
6,940 KB
testcase_50 AC 279 ms
6,940 KB
testcase_51 AC 281 ms
6,940 KB
testcase_52 AC 283 ms
6,940 KB
testcase_53 AC 283 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let (n, d): (usize, i32) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let mut fav = Vec::with_capacity(n);
    for _ in 0..n {
        let a: i32 = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            buf.trim_end().parse().unwrap()
        };
        fav.push(a);
    }
    let mut sorted_fav = fav.iter().cloned().collect::<Vec<_>>();
    sorted_fav.sort();
    for a in fav {
        let mut left = 0;
        let mut right = n;
        while left < right {
            let mid = (left + right) / 2;
            if a - sorted_fav[mid] >= d {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        println!("{}", left);
    }
}
0