結果

問題 No.1110 好きな歌
ユーザー tonyu0tonyu0
提出日時 2020-07-10 22:09:32
言語 Rust
(1.77.0)
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 903 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 173,840 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 17:21:19
合計ジャッジ時間 4,492 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 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 0 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 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 29 ms
5,376 KB
testcase_25 AC 33 ms
5,396 KB
testcase_26 AC 19 ms
5,376 KB
testcase_27 AC 36 ms
5,376 KB
testcase_28 AC 19 ms
5,376 KB
testcase_29 AC 47 ms
6,008 KB
testcase_30 AC 17 ms
5,376 KB
testcase_31 AC 11 ms
5,376 KB
testcase_32 AC 50 ms
6,468 KB
testcase_33 AC 17 ms
5,376 KB
testcase_34 AC 27 ms
5,376 KB
testcase_35 AC 38 ms
6,240 KB
testcase_36 AC 5 ms
5,376 KB
testcase_37 AC 15 ms
5,376 KB
testcase_38 AC 45 ms
5,964 KB
testcase_39 AC 32 ms
5,376 KB
testcase_40 AC 31 ms
5,376 KB
testcase_41 AC 4 ms
5,376 KB
testcase_42 AC 39 ms
5,892 KB
testcase_43 AC 44 ms
5,860 KB
testcase_44 AC 43 ms
6,116 KB
testcase_45 AC 50 ms
6,636 KB
testcase_46 AC 47 ms
6,624 KB
testcase_47 AC 57 ms
6,888 KB
testcase_48 AC 48 ms
6,500 KB
testcase_49 AC 37 ms
5,992 KB
testcase_50 AC 49 ms
6,628 KB
testcase_51 AC 45 ms
6,372 KB
testcase_52 AC 49 ms
6,508 KB
testcase_53 AC 56 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::cmp::*;
use std::io::*;

fn lower_bound<T: PartialOrd>(x: T, a: &Vec<T>) -> usize {
    let mut l: usize = 0;
    let mut r: usize = a.len();
    while r != l {
        let mid = (l + r) >> 1;
        if a[mid] < x {
            l = mid + 1;
        } else {
            r = mid;
        }
    }
    l
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let d: i32 = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i32> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let b = a.clone();
    a.sort();
    let mut out = Vec::new();
    // a_i - a_j >= d
    for i in 0..n {
        writeln!(out, "{}", lower_bound(b[i] - d + 1, &a)).ok();
    }
    stdout().write_all(&out).unwrap();
}
0