結果

問題 No.1110 好きな歌
ユーザー jjjjjjjtgpptmjjjjjjjjjtgpptmjj
提出日時 2020-07-10 22:14:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 317 ms / 5,000 ms
コード長 1,761 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 208,940 KB
実行使用メモリ 9,276 KB
最終ジャッジ日時 2023-08-01 18:15:47
合計ジャッジ時間 12,159 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 185 ms
5,856 KB
testcase_25 AC 228 ms
7,760 KB
testcase_26 AC 116 ms
5,224 KB
testcase_27 AC 222 ms
8,892 KB
testcase_28 AC 127 ms
5,064 KB
testcase_29 AC 260 ms
8,408 KB
testcase_30 AC 128 ms
5,200 KB
testcase_31 AC 78 ms
4,432 KB
testcase_32 AC 284 ms
8,104 KB
testcase_33 AC 144 ms
5,328 KB
testcase_34 AC 194 ms
6,104 KB
testcase_35 AC 304 ms
8,468 KB
testcase_36 AC 35 ms
4,380 KB
testcase_37 AC 87 ms
4,432 KB
testcase_38 AC 253 ms
9,092 KB
testcase_39 AC 191 ms
6,076 KB
testcase_40 AC 243 ms
7,776 KB
testcase_41 AC 20 ms
4,384 KB
testcase_42 AC 278 ms
7,380 KB
testcase_43 AC 268 ms
7,664 KB
testcase_44 AC 308 ms
8,044 KB
testcase_45 AC 310 ms
7,628 KB
testcase_46 AC 317 ms
9,276 KB
testcase_47 AC 314 ms
7,868 KB
testcase_48 AC 312 ms
7,772 KB
testcase_49 AC 301 ms
7,680 KB
testcase_50 AC 307 ms
7,912 KB
testcase_51 AC 310 ms
8,132 KB
testcase_52 AC 315 ms
7,772 KB
testcase_53 AC 314 ms
7,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, D;
    cin >> N >> D;
    vector<l_l> A;
    rep(i, N){
        ll a;
        cin >> a;
        A.push_back({a, i});
    }
    sort(all(A));
    // あるiについてA_j <= A_i - Dとなるjの個数
    vector<ll> ans(N);
    rep(i,N){
        int idx = A[i].second;
        l_l ue = make_pair(A[i].first - D, INFLL);
        ans[idx] = upper_bound(all(A), ue) - A.begin();
    }
    rep(i,N){
        cout << ans[i] << endl;
    }
}
0