結果

問題 No.1110 好きな歌
ユーザー goto_isyuku
提出日時 2020-07-10 21:38:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 926 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 171,788 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-11 13:09:05
合計ジャッジ時間 27,643 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

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

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>
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(){

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

    vector<int> a(n);
    vector<int> v(n);
    rep(i, n){
        cin >> a[i];
        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