結果

問題 No.1110 好きな歌
ユーザー shell_mugshell_mug
提出日時 2020-07-10 22:08:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 2,131 bytes
コンパイル時間 1,370 ms
コンパイル使用メモリ 117,220 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-04-19 17:19:29
合計ジャッジ時間 5,844 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 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 2 ms
5,376 KB
testcase_24 AC 52 ms
5,504 KB
testcase_25 AC 63 ms
6,144 KB
testcase_26 AC 32 ms
5,376 KB
testcase_27 AC 61 ms
6,016 KB
testcase_28 AC 35 ms
5,376 KB
testcase_29 AC 70 ms
6,400 KB
testcase_30 AC 36 ms
5,376 KB
testcase_31 AC 22 ms
5,376 KB
testcase_32 AC 82 ms
6,784 KB
testcase_33 AC 40 ms
5,376 KB
testcase_34 AC 53 ms
5,760 KB
testcase_35 AC 83 ms
7,168 KB
testcase_36 AC 9 ms
5,376 KB
testcase_37 AC 23 ms
5,376 KB
testcase_38 AC 71 ms
6,528 KB
testcase_39 AC 52 ms
5,760 KB
testcase_40 AC 68 ms
6,400 KB
testcase_41 AC 6 ms
5,376 KB
testcase_42 AC 81 ms
6,912 KB
testcase_43 AC 73 ms
6,528 KB
testcase_44 AC 88 ms
7,168 KB
testcase_45 AC 94 ms
7,168 KB
testcase_46 AC 89 ms
7,168 KB
testcase_47 AC 88 ms
7,168 KB
testcase_48 AC 86 ms
7,168 KB
testcase_49 AC 82 ms
7,168 KB
testcase_50 AC 86 ms
7,296 KB
testcase_51 AC 86 ms
7,168 KB
testcase_52 AC 87 ms
7,168 KB
testcase_53 AC 91 ms
7,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d; cin >> n >> d;
    vector<int> a(n); rep (i, a.size()) cin >> a[i];
    vector<P> b(n); rep (i, a.size()) b[i] = P{a[i], i};
    sort(all(b));
    rep (i, n) eprintf("(%d,%d)", b[i].first, b[i].second); eprintf("\n");
    vector<P> c(n); rep (i, a.size()) c[i].first = b[i].second;
    c[0].second = 0;
    rep (i, n) {
        int ok = -1, ng = n;
        while (abs(ok - ng) > 1) {
            int med = (ok + ng) / 2;
            if (b[i].first - b[med].first >= d) ok = med;
            else ng = med;
        }
        c[i].second = ok + 1;
    }
    rep (i, n) eprintf("(%d,%d)", c[i].first, c[i].second); eprintf("\n");
    sort(all(c));
    rep (i, n) eprintf("(%d,%d)", c[i].first, c[i].second); eprintf("\n");
    rep (i, n) cout << c[i].second << "\n";
    return 0;
}
0