結果

問題 No.1110 好きな歌
ユーザー RuiRui
提出日時 2022-12-13 12:51:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 400 ms / 5,000 ms
コード長 963 bytes
コンパイル時間 2,009 ms
コンパイル使用メモリ 169,076 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 23:31:10
合計ジャッジ時間 14,835 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 228 ms
5,376 KB
testcase_25 AC 277 ms
5,376 KB
testcase_26 AC 147 ms
5,376 KB
testcase_27 AC 276 ms
5,376 KB
testcase_28 AC 160 ms
5,376 KB
testcase_29 AC 338 ms
5,376 KB
testcase_30 AC 153 ms
5,376 KB
testcase_31 AC 96 ms
5,376 KB
testcase_32 AC 374 ms
5,376 KB
testcase_33 AC 181 ms
5,376 KB
testcase_34 AC 249 ms
5,376 KB
testcase_35 AC 373 ms
5,376 KB
testcase_36 AC 41 ms
5,376 KB
testcase_37 AC 109 ms
5,376 KB
testcase_38 AC 327 ms
5,376 KB
testcase_39 AC 243 ms
5,376 KB
testcase_40 AC 298 ms
5,376 KB
testcase_41 AC 25 ms
5,376 KB
testcase_42 AC 341 ms
5,376 KB
testcase_43 AC 325 ms
5,376 KB
testcase_44 AC 379 ms
5,376 KB
testcase_45 AC 388 ms
5,376 KB
testcase_46 AC 388 ms
5,376 KB
testcase_47 AC 400 ms
5,376 KB
testcase_48 AC 388 ms
5,376 KB
testcase_49 AC 364 ms
5,376 KB
testcase_50 AC 390 ms
5,376 KB
testcase_51 AC 380 ms
5,376 KB
testcase_52 AC 390 ms
5,376 KB
testcase_53 AC 400 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
//typedef modint1000000007 mint;
const int MOD = 1000000007;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
    int n, d;
    cin >> n >> d;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> b = a;
    sort(all(b));

    rep(i, n){
        if(a[i] < b[0] + d){
            cout << 0 << endl;
            continue;
        }
        auto it = lower_bound(all(b), a[i] - d + 1);
        cout << it - b.begin() << endl;
    }

    return 0;
}
0