結果

問題 No.1110 好きな歌
ユーザー kappybarkappybar
提出日時 2020-07-10 21:35:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 352 ms / 5,000 ms
コード長 806 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 172,156 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2024-04-19 16:05:08
合計ジャッジ時間 11,375 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 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 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 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 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 203 ms
6,656 KB
testcase_25 AC 243 ms
7,168 KB
testcase_26 AC 129 ms
5,376 KB
testcase_27 AC 240 ms
7,168 KB
testcase_28 AC 139 ms
5,760 KB
testcase_29 AC 278 ms
7,748 KB
testcase_30 AC 143 ms
5,632 KB
testcase_31 AC 87 ms
5,376 KB
testcase_32 AC 328 ms
8,192 KB
testcase_33 AC 166 ms
5,888 KB
testcase_34 AC 217 ms
6,784 KB
testcase_35 AC 352 ms
8,616 KB
testcase_36 AC 43 ms
5,376 KB
testcase_37 AC 93 ms
5,376 KB
testcase_38 AC 271 ms
7,604 KB
testcase_39 AC 209 ms
6,784 KB
testcase_40 AC 270 ms
7,552 KB
testcase_41 AC 20 ms
5,376 KB
testcase_42 AC 308 ms
8,320 KB
testcase_43 AC 276 ms
7,680 KB
testcase_44 AC 338 ms
8,636 KB
testcase_45 AC 348 ms
8,704 KB
testcase_46 AC 341 ms
8,764 KB
testcase_47 AC 329 ms
8,832 KB
testcase_48 AC 345 ms
8,832 KB
testcase_49 AC 335 ms
8,832 KB
testcase_50 AC 341 ms
8,704 KB
testcase_51 AC 336 ms
8,660 KB
testcase_52 AC 340 ms
8,660 KB
testcase_53 AC 344 ms
8,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    ll d;
    cin >> n >> d;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<pll> p(n);
    rep(i,n) p[i] = pll(a[i],i);
    sort(p.begin(),p.end());
    vector<int> ans(n);
    rep(i,n){
        ll k = p[i].first;
        int l = -1,r = n;
        while(r - l > 1){
            int m = (l+r)/2;
            if(k-p[m].first>=d) l = m;
            else r = m;
        }
        ans[p[i].second] = r;
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}
0