結果

問題 No.1170 Never Want to Walk
ユーザー hiro71687khiro71687k
提出日時 2023-02-27 05:10:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 462 ms / 2,000 ms
コード長 1,531 bytes
コンパイル時間 4,289 ms
コンパイル使用メモリ 268,020 KB
実行使用メモリ 19,052 KB
最終ジャッジ日時 2023-10-12 17:17:32
合計ジャッジ時間 11,968 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 3 ms
4,352 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 4 ms
4,352 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 3 ms
4,352 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 4 ms
4,352 KB
testcase_21 AC 3 ms
4,352 KB
testcase_22 AC 3 ms
4,352 KB
testcase_23 AC 3 ms
4,352 KB
testcase_24 AC 3 ms
4,352 KB
testcase_25 AC 4 ms
4,352 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 452 ms
19,052 KB
testcase_28 AC 435 ms
17,876 KB
testcase_29 AC 462 ms
18,404 KB
testcase_30 AC 454 ms
18,416 KB
testcase_31 AC 440 ms
18,152 KB
testcase_32 AC 424 ms
18,144 KB
testcase_33 AC 428 ms
17,860 KB
testcase_34 AC 429 ms
18,404 KB
testcase_35 AC 425 ms
18,348 KB
testcase_36 AC 413 ms
18,152 KB
testcase_37 AC 414 ms
18,064 KB
testcase_38 AC 435 ms
18,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ll inf=10010010010010010;
ll mod=998244353;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll>x(n);
    set<pair<ll,ll>>s;
    s.insert({inf,inf});
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i];
        s.insert({x[i],i});
    }
    vector<ll>ans(n);
    while (1)
    {
        auto v=s.lower_bound({-1,-1});
        pair<ll,ll>p=*(v);
        s.erase(p);
        if (p.first==inf)
        {
            break;
        }
        vector<pair<ll,ll>>memo;
        memo.push_back(p);
        for (ll i = 0; i < memo.size(); i++)
        {
            v=s.lower_bound({memo[i].first+a,-1});
            pair<ll,ll>q=*(v);
            while (a<=abs(q.first-memo[i].first)&&abs(q.first-memo[i].first)<=b)
            {
                s.erase(q);
                memo.push_back(q);
                v=s.lower_bound(q);
                q=*(v);
            }
            v=s.lower_bound({memo[i].first-b,-1});
            q=*(v);
            while (a<=abs(memo[i].first-q.first)&&abs(memo[i].first-q.first)<=b)
            {
                s.erase(q);
                memo.push_back(q);
                v=s.lower_bound(q);
                q=*(v);
            }
        }
        for (ll i = 0; i < memo.size(); i++)
        {
            ans[memo[i].second]=memo.size();
        }
    }
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    
}
0