結果

問題 No.1110 好きな歌
ユーザー tanimani364tanimani364
提出日時 2020-07-10 21:38:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 71 ms / 5,000 ms
コード長 1,307 bytes
コンパイル時間 2,439 ms
コンパイル使用メモリ 204,940 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-04-19 16:18:49
合計ジャッジ時間 6,606 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 2 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 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 40 ms
6,912 KB
testcase_25 AC 46 ms
7,552 KB
testcase_26 AC 24 ms
5,504 KB
testcase_27 AC 51 ms
7,552 KB
testcase_28 AC 30 ms
5,760 KB
testcase_29 AC 60 ms
8,320 KB
testcase_30 AC 27 ms
5,888 KB
testcase_31 AC 17 ms
5,376 KB
testcase_32 AC 65 ms
8,832 KB
testcase_33 AC 29 ms
6,144 KB
testcase_34 AC 43 ms
7,296 KB
testcase_35 AC 63 ms
9,344 KB
testcase_36 AC 9 ms
5,376 KB
testcase_37 AC 19 ms
5,376 KB
testcase_38 AC 58 ms
8,320 KB
testcase_39 AC 43 ms
7,040 KB
testcase_40 AC 51 ms
8,192 KB
testcase_41 AC 5 ms
5,376 KB
testcase_42 AC 55 ms
8,704 KB
testcase_43 AC 59 ms
8,320 KB
testcase_44 AC 64 ms
9,472 KB
testcase_45 AC 66 ms
9,344 KB
testcase_46 AC 66 ms
9,472 KB
testcase_47 AC 71 ms
9,472 KB
testcase_48 AC 68 ms
9,412 KB
testcase_49 AC 64 ms
9,344 KB
testcase_50 AC 65 ms
9,472 KB
testcase_51 AC 65 ms
9,344 KB
testcase_52 AC 65 ms
9,472 KB
testcase_53 AC 67 ms
9,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

using P=pair<ll,ll>;
void solve()
{
	ll n,d;
	cin>>n>>d;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	vector<P>v(n);
	rep(i,n)v[i]={a[i],i};
	sort(all(v));
	vector<ll>ans(n);
	rep(i,n){
		ans[v[i].second]=lower_bound(all(v),P{v[i].first-d,INF})-v.begin();
	}
	rep(i,n){
		cout<<ans[i]<<"\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0