結果

問題 No.1110 好きな歌
ユーザー goto_isyukugoto_isyuku
提出日時 2020-07-10 22:40:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 1,406 bytes
コンパイル時間 1,421 ms
コンパイル使用メモリ 168,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 17:53:33
合計ジャッジ時間 5,539 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 39 ms
6,940 KB
testcase_25 AC 46 ms
6,944 KB
testcase_26 AC 28 ms
6,944 KB
testcase_27 AC 49 ms
6,944 KB
testcase_28 AC 27 ms
6,940 KB
testcase_29 AC 61 ms
6,944 KB
testcase_30 AC 24 ms
6,944 KB
testcase_31 AC 16 ms
6,944 KB
testcase_32 AC 65 ms
6,940 KB
testcase_33 AC 26 ms
6,944 KB
testcase_34 AC 40 ms
6,944 KB
testcase_35 AC 56 ms
6,940 KB
testcase_36 AC 8 ms
6,944 KB
testcase_37 AC 20 ms
6,944 KB
testcase_38 AC 60 ms
6,940 KB
testcase_39 AC 43 ms
6,940 KB
testcase_40 AC 43 ms
6,940 KB
testcase_41 AC 5 ms
6,940 KB
testcase_42 AC 55 ms
6,940 KB
testcase_43 AC 58 ms
6,940 KB
testcase_44 AC 59 ms
6,940 KB
testcase_45 AC 70 ms
6,944 KB
testcase_46 AC 65 ms
6,944 KB
testcase_47 AC 78 ms
6,940 KB
testcase_48 AC 69 ms
6,944 KB
testcase_49 AC 51 ms
6,940 KB
testcase_50 AC 66 ms
6,940 KB
testcase_51 AC 61 ms
6,940 KB
testcase_52 AC 68 ms
6,944 KB
testcase_53 AC 75 ms
6,944 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;
}

//最大値 ULONG_MAX
inline uint32_t xor128(void) { 
  static uint32_t x = 123456789;
  static uint32_t y = 362436069;
  static uint32_t z = 521288629;
  static uint32_t w = 88675123; 
  uint32_t t;
 
  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); 
}

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;
        auto it = upper_bound(ALL(v), tmp);
        cout << it - v.begin() << endl;
    }

    return 0;
}
0