結果

問題 No.1170 Never Want to Walk
ユーザー Akidai16Akidai16
提出日時 2022-04-08 01:18:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 1,181 bytes
コンパイル時間 3,850 ms
コンパイル使用メモリ 228,204 KB
実行使用メモリ 4,964 KB
最終ジャッジ日時 2023-08-18 19:15:59
合計ジャッジ時間 11,026 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 315 ms
4,656 KB
testcase_28 AC 299 ms
4,800 KB
testcase_29 AC 309 ms
4,612 KB
testcase_30 AC 305 ms
4,608 KB
testcase_31 AC 296 ms
4,672 KB
testcase_32 AC 292 ms
4,964 KB
testcase_33 AC 302 ms
4,804 KB
testcase_34 AC 303 ms
4,608 KB
testcase_35 AC 308 ms
4,620 KB
testcase_36 AC 295 ms
4,740 KB
testcase_37 AC 293 ms
4,624 KB
testcase_38 AC 311 ms
4,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define All(A) A.begin(), A.end()
#define rAll(A) A.rbegin(), A.rend()

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int N, A, B;
vi X;

void solve() {
    dsu C(N);
    int range_min = 0;
    int j = lower_bound(X.begin(), X.end(), X[0] + A) - X.begin();
    REP(i, 0, N) {
        // cout << i << " " << j << endl;
        int range_min = lower_bound(X.begin(), X.end(), X[i] + A) - X.begin();
        j = max(j - 1, range_min);
        auto itr = upper_bound(X.begin(), X.end(), X[i] + B);
        // cout << itr - X.begin() << endl;
        while(j < itr - X.begin()) {
            C.merge(i, j);
            j++;
        }
    }
    REP(i, 0, N) {
        cout << C.size(i) << endl;
    }
}

int main() {
    cin >> N >> A >> B;
    X.resize(N);
    REP(i, 0, N) {
        cin >> X[i];
    }
    solve();
}
0