結果

問題 No.1110 好きな歌
ユーザー ks2mks2m
提出日時 2020-07-10 21:42:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,314 ms / 5,000 ms
コード長 998 bytes
コンパイル時間 2,522 ms
コンパイル使用メモリ 80,432 KB
実行使用メモリ 55,552 KB
最終ジャッジ日時 2024-04-19 16:31:19
合計ジャッジ時間 33,715 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
37,556 KB
testcase_01 AC 67 ms
37,516 KB
testcase_02 AC 64 ms
37,692 KB
testcase_03 AC 66 ms
37,568 KB
testcase_04 AC 62 ms
37,868 KB
testcase_05 AC 66 ms
37,656 KB
testcase_06 AC 67 ms
37,688 KB
testcase_07 AC 63 ms
37,624 KB
testcase_08 AC 64 ms
37,772 KB
testcase_09 AC 70 ms
37,760 KB
testcase_10 AC 62 ms
37,732 KB
testcase_11 AC 69 ms
37,592 KB
testcase_12 AC 73 ms
37,896 KB
testcase_13 AC 62 ms
37,756 KB
testcase_14 AC 82 ms
38,236 KB
testcase_15 AC 72 ms
38,072 KB
testcase_16 AC 86 ms
38,144 KB
testcase_17 AC 91 ms
38,384 KB
testcase_18 AC 63 ms
37,356 KB
testcase_19 AC 97 ms
38,712 KB
testcase_20 AC 92 ms
38,332 KB
testcase_21 AC 80 ms
38,076 KB
testcase_22 AC 81 ms
38,380 KB
testcase_23 AC 79 ms
38,108 KB
testcase_24 AC 787 ms
52,584 KB
testcase_25 AC 852 ms
52,892 KB
testcase_26 AC 489 ms
49,692 KB
testcase_27 AC 880 ms
52,452 KB
testcase_28 AC 531 ms
50,492 KB
testcase_29 AC 997 ms
53,920 KB
testcase_30 AC 501 ms
50,472 KB
testcase_31 AC 364 ms
47,328 KB
testcase_32 AC 1,068 ms
54,360 KB
testcase_33 AC 559 ms
51,184 KB
testcase_34 AC 761 ms
52,884 KB
testcase_35 AC 1,021 ms
54,760 KB
testcase_36 AC 240 ms
44,096 KB
testcase_37 AC 392 ms
48,588 KB
testcase_38 AC 989 ms
54,156 KB
testcase_39 AC 696 ms
52,400 KB
testcase_40 AC 939 ms
53,360 KB
testcase_41 AC 196 ms
42,888 KB
testcase_42 AC 1,018 ms
54,720 KB
testcase_43 AC 1,017 ms
53,844 KB
testcase_44 AC 1,150 ms
55,552 KB
testcase_45 AC 1,255 ms
54,636 KB
testcase_46 AC 1,310 ms
54,872 KB
testcase_47 AC 1,255 ms
54,520 KB
testcase_48 AC 1,276 ms
54,564 KB
testcase_49 AC 1,155 ms
54,724 KB
testcase_50 AC 1,314 ms
54,652 KB
testcase_51 AC 1,196 ms
54,860 KB
testcase_52 AC 1,260 ms
54,452 KB
testcase_53 AC 1,231 ms
54,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int d = Integer.parseInt(sa[1]);
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.a = Integer.parseInt(br.readLine());
			o.i = i;
			arr[i] = o;
		}
		br.close();

		Arrays.sort(arr, (o1, o2) -> o2.a - o1.a);
		int j = 1;
		for (int i = 0; i < n; i++) {
			while (j < n && arr[i].a - arr[j].a < d) {
				j++;
			}
			if (j < n && arr[i].a - arr[j].a >= d) {
				arr[i].ans = n - j;
			}
		}

		Arrays.sort(arr, (o1, o2) -> o1.i - o2.i);
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			pw.println(arr[i].ans);
		}
		pw.flush();
	}

	static class Obj {
		int a, i, ans;
	}
}
0