結果

問題 No.1110 好きな歌
ユーザー lasjg72
提出日時 2020-07-10 23:40:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 575 ms / 5,000 ms
コード長 723 bytes
コンパイル時間 1,205 ms
コンパイル使用メモリ 95,508 KB
実行使用メモリ 14,208 KB
最終ジャッジ日時 2024-10-11 19:27:46
合計ジャッジ時間 16,211 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n, d;
    cin >> n >> d;
    vector<int> a(n);
    map<int, int> num;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> b(n);
    b = a;
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        if(a[i]-d < a[0]){
            num[a[i]] = 0;
            continue;
        }
        int itr = upper_bound(a.begin(), a.end(), a[i]-d)-a.begin();
        num[a[i]] = itr;
    }
    for(int i = 0; i < n; i++){
        cout << num[b[i]] << endl; 
    }
    return 0;
}
0