結果

問題 No.1110 好きな歌
ユーザー goto_isyukugoto_isyuku
提出日時 2020-07-10 23:32:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 1,070 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 169,828 KB
実行使用メモリ 4,800 KB
最終ジャッジ日時 2023-08-01 23:32:04
合計ジャッジ時間 6,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 42 ms
4,400 KB
testcase_25 AC 49 ms
4,380 KB
testcase_26 AC 27 ms
4,380 KB
testcase_27 AC 52 ms
4,376 KB
testcase_28 AC 29 ms
4,380 KB
testcase_29 AC 63 ms
4,384 KB
testcase_30 AC 28 ms
4,376 KB
testcase_31 AC 18 ms
4,380 KB
testcase_32 AC 71 ms
4,376 KB
testcase_33 AC 31 ms
4,380 KB
testcase_34 AC 45 ms
4,376 KB
testcase_35 AC 67 ms
4,572 KB
testcase_36 AC 8 ms
4,380 KB
testcase_37 AC 21 ms
4,380 KB
testcase_38 AC 62 ms
4,388 KB
testcase_39 AC 45 ms
4,380 KB
testcase_40 AC 53 ms
4,380 KB
testcase_41 AC 5 ms
4,380 KB
testcase_42 AC 61 ms
4,388 KB
testcase_43 AC 61 ms
4,380 KB
testcase_44 AC 69 ms
4,624 KB
testcase_45 AC 74 ms
4,584 KB
testcase_46 AC 72 ms
4,608 KB
testcase_47 AC 78 ms
4,684 KB
testcase_48 AC 73 ms
4,636 KB
testcase_49 AC 65 ms
4,552 KB
testcase_50 AC 74 ms
4,800 KB
testcase_51 AC 70 ms
4,624 KB
testcase_52 AC 73 ms
4,568 KB
testcase_53 AC 78 ms
4,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

//ソート済み配列に対して、指定した数以下の個数を返す関数
template<typename T>
inline int less_or_eq_count(std::vector<T> &v, T x){
    
    int ok = -1;
    int ng = v.size();

    while(ng - ok > 1){
        int tmp = (ok + ng) / 2;

        if(v[tmp] <= x){
            ok = tmp;
        }else ng = tmp;
    }

    return ok + 1;
}

int main(){

    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n, d;
    cin >> n >> d;

    assert(n <= 200000);

    vector<int> a(n);
    vector<int> v(n);
    int tmp;
    rep(i, n){
        cin >> tmp;
        a[i] = tmp;
        v[i] = a[i];
    }

    sort(ALL(v));

    rep(i, n){
        int tmp = a[i] - d;
        cout << less_or_eq_count(v, tmp) << endl;
    }

    return 0;
}
0