結果

問題 No.1110 好きな歌
ユーザー 👑 platinumplatinum
提出日時 2020-05-27 22:32:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 370 ms / 5,000 ms
コード長 605 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 172,268 KB
実行使用メモリ 5,524 KB
最終ジャッジ日時 2023-08-03 06:13:29
合計ジャッジ時間 13,227 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 3 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,384 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 219 ms
4,384 KB
testcase_25 AC 259 ms
4,612 KB
testcase_26 AC 137 ms
4,384 KB
testcase_27 AC 255 ms
4,620 KB
testcase_28 AC 150 ms
4,380 KB
testcase_29 AC 298 ms
4,880 KB
testcase_30 AC 151 ms
4,384 KB
testcase_31 AC 91 ms
4,384 KB
testcase_32 AC 332 ms
5,136 KB
testcase_33 AC 168 ms
4,380 KB
testcase_34 AC 235 ms
4,728 KB
testcase_35 AC 351 ms
5,388 KB
testcase_36 AC 40 ms
4,384 KB
testcase_37 AC 100 ms
4,380 KB
testcase_38 AC 301 ms
4,824 KB
testcase_39 AC 226 ms
4,476 KB
testcase_40 AC 282 ms
4,824 KB
testcase_41 AC 23 ms
4,384 KB
testcase_42 AC 329 ms
5,092 KB
testcase_43 AC 306 ms
4,996 KB
testcase_44 AC 358 ms
5,464 KB
testcase_45 AC 361 ms
5,468 KB
testcase_46 AC 367 ms
5,516 KB
testcase_47 AC 370 ms
5,408 KB
testcase_48 AC 359 ms
5,472 KB
testcase_49 AC 357 ms
5,524 KB
testcase_50 AC 361 ms
5,348 KB
testcase_51 AC 361 ms
5,408 KB
testcase_52 AC 366 ms
5,476 KB
testcase_53 AC 362 ms
5,352 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>;
const int INF=1e9;
const int Max_N=2e5;
const int Max_A=1e9;

int main(){
	int N, D;
	cin >> N >> D;
	assert(N>=1 && N<=Max_N);
	assert(D>=1 && D<=Max_A);
	vector<P> A(N);
	rep(i,N){
		int a;
		cin >> a;
		assert(a>=1 && a<=Max_A);
		A[i]={a,i};
	}
	sort(A.begin(),A.end());
	vector<int> ans(N);
	rep(i,N){
		int a=A[i].first;
		int res=upper_bound(A.begin(),A.end(),P(a-D,INF))-A.begin();
		ans[A[i].second]=res;
	}
	rep(i,N) cout << ans[i] << endl;

	return 0;
}
0