結果

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

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}


int main() {
	int n = ri();
	int d = ri();
	std::pair<int, int> a[n];
	for (int i = 0; i < n; i++) a[i] = {ri(), i};
	std::sort(a, a + n);
	int res[n];
	int head = 0;
	for (int i = 0; i < n; i++) {
		while (head < n && a[head].first <= a[i].first - d) head++;
		res[a[i].second] = head;
	}
	for (auto i : res) printf("%d\n", i);
	return 0;
}
0