結果

問題 No.1110 好きな歌
ユーザー goto_isyukugoto_isyuku
提出日時 2020-07-10 23:32:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 1,079 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 170,124 KB
実行使用メモリ 4,796 KB
最終ジャッジ日時 2023-08-01 23:29:17
合計ジャッジ時間 7,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 41 ms
4,380 KB
testcase_25 AC 52 ms
4,384 KB
testcase_26 AC 26 ms
4,380 KB
testcase_27 AC 50 ms
4,376 KB
testcase_28 AC 28 ms
4,380 KB
testcase_29 AC 61 ms
4,376 KB
testcase_30 AC 27 ms
4,376 KB
testcase_31 AC 17 ms
4,380 KB
testcase_32 AC 71 ms
4,708 KB
testcase_33 AC 31 ms
4,380 KB
testcase_34 AC 45 ms
4,380 KB
testcase_35 AC 65 ms
4,620 KB
testcase_36 AC 7 ms
4,380 KB
testcase_37 AC 20 ms
4,380 KB
testcase_38 AC 64 ms
4,380 KB
testcase_39 AC 45 ms
4,376 KB
testcase_40 AC 52 ms
4,376 KB
testcase_41 AC 5 ms
4,380 KB
testcase_42 AC 61 ms
4,376 KB
testcase_43 AC 59 ms
4,380 KB
testcase_44 AC 66 ms
4,688 KB
testcase_45 AC 73 ms
4,568 KB
testcase_46 AC 69 ms
4,588 KB
testcase_47 AC 80 ms
4,528 KB
testcase_48 AC 74 ms
4,644 KB
testcase_49 AC 65 ms
4,556 KB
testcase_50 AC 72 ms
4,692 KB
testcase_51 AC 70 ms
4,648 KB
testcase_52 AC 76 ms
4,620 KB
testcase_53 AC 80 ms
4,796 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 size){
    
    int ok = -1;
    int ng = 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, n) << endl;
    }

    return 0;
}
0