結果

問題 No.1110 好きな歌
ユーザー goto_isyukugoto_isyuku
提出日時 2020-07-10 21:52:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,282 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 168,664 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 16:51:23
合計ジャッジ時間 6,622 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
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 1 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 1 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 53 ms
5,376 KB
testcase_31 AC 32 ms
5,376 KB
testcase_32 WA -
testcase_33 AC 56 ms
5,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 15 ms
5,376 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 8 ms
5,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 115 ms
5,376 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

//ソート済みの関数と値を入力すると
//値が存在するかのboolと値未満の個数(trueなら値のあるでもあるindex)を返す
template<typename T> 
auto binsearch_idx(vector<T> &v, T val, ll size){
    // leftがlessの右端のindex,rightがeq,greaterの左端のindex
    ll left = -1, right = size;
    while( abs(right - left) > 1)
    {
        ll mid = (left + right) / 2;
        if (v[mid] < val)
            left = mid;
        else
            right = mid;
    }
    
    // vにvalが存在するなら,{true, 左端のindex}
    // 存在しないなら,{false, val未満の個数}
    return (make_pair(v[right] == val, right));
}

int main(){

    int n, d;
    cin >> n >> d;

    vector<int> a(n);
    vector<int> v(n);
    rep(i, n){
        cin >> a[i];
        v[i] = a[i];
    }

    sort(ALL(v));

    rep(i, n){
        int tmp = a[i] - d;
        pair<bool, int> p = binsearch_idx(v, tmp, n);
        cout << p.second << "\n";
    }

    return 0;
}
0