結果

問題 No.1110 好きな歌
ユーザー siro53siro53
提出日時 2020-07-10 22:23:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 1,602 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 202,972 KB
実行使用メモリ 7,656 KB
最終ジャッジ日時 2024-04-19 17:34:28
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 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 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 39 ms
5,728 KB
testcase_25 AC 47 ms
7,524 KB
testcase_26 AC 25 ms
5,376 KB
testcase_27 AC 46 ms
7,520 KB
testcase_28 AC 27 ms
5,476 KB
testcase_29 AC 56 ms
7,656 KB
testcase_30 AC 26 ms
5,476 KB
testcase_31 AC 17 ms
5,376 KB
testcase_32 AC 62 ms
7,524 KB
testcase_33 AC 30 ms
5,476 KB
testcase_34 AC 42 ms
5,860 KB
testcase_35 AC 63 ms
7,524 KB
testcase_36 AC 8 ms
5,376 KB
testcase_37 AC 20 ms
5,376 KB
testcase_38 AC 54 ms
7,524 KB
testcase_39 AC 40 ms
5,604 KB
testcase_40 AC 52 ms
7,528 KB
testcase_41 AC 5 ms
5,376 KB
testcase_42 AC 57 ms
7,396 KB
testcase_43 AC 57 ms
7,528 KB
testcase_44 AC 64 ms
7,528 KB
testcase_45 AC 68 ms
7,528 KB
testcase_46 AC 64 ms
7,456 KB
testcase_47 AC 66 ms
7,528 KB
testcase_48 AC 64 ms
7,652 KB
testcase_49 AC 59 ms
7,528 KB
testcase_50 AC 64 ms
7,400 KB
testcase_51 AC 65 ms
7,392 KB
testcase_52 AC 70 ms
7,520 KB
testcase_53 AC 67 ms
7,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll d;
    cin >> n >> d;
    vector<pair<ll, int>> v;
    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        v.emplace_back(a, i);
    }
    sort(ALL(v));
    // for(int i = 0; i < n; i++) {
    //     cerr << v[i].first << " " << v[i].second << endl;
    // }
    vector<int> ans(n);
    for(int i = 0; i < n; i++) {
        auto it = upper_bound(ALL(v), make_pair(v[i].first - d, INF));
        it--;
        ans[v[i].second] = it - v.begin() + 1;
    }
    for(auto i : ans) {
        cout << i << "\n";
    }
}
0