結果
問題 | No.1110 好きな歌 |
ユーザー | shojin_pro |
提出日時 | 2020-07-10 21:51:06 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,802 ms / 5,000 ms |
コード長 | 2,591 bytes |
コンパイル時間 | 2,317 ms |
コンパイル使用メモリ | 79,936 KB |
実行使用メモリ | 64,948 KB |
最終ジャッジ日時 | 2024-10-11 08:54:54 |
合計ジャッジ時間 | 47,627 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
36,796 KB |
testcase_01 | AC | 54 ms
37,044 KB |
testcase_02 | AC | 54 ms
37,280 KB |
testcase_03 | AC | 52 ms
37,104 KB |
testcase_04 | AC | 53 ms
36,960 KB |
testcase_05 | AC | 53 ms
36,904 KB |
testcase_06 | AC | 53 ms
36,772 KB |
testcase_07 | AC | 52 ms
37,112 KB |
testcase_08 | AC | 54 ms
37,092 KB |
testcase_09 | AC | 53 ms
36,768 KB |
testcase_10 | AC | 53 ms
36,776 KB |
testcase_11 | AC | 53 ms
37,160 KB |
testcase_12 | AC | 54 ms
37,096 KB |
testcase_13 | AC | 53 ms
36,904 KB |
testcase_14 | AC | 86 ms
38,196 KB |
testcase_15 | AC | 74 ms
37,864 KB |
testcase_16 | AC | 84 ms
38,104 KB |
testcase_17 | AC | 109 ms
38,516 KB |
testcase_18 | AC | 57 ms
37,172 KB |
testcase_19 | AC | 112 ms
38,684 KB |
testcase_20 | AC | 115 ms
38,648 KB |
testcase_21 | AC | 78 ms
37,960 KB |
testcase_22 | AC | 102 ms
38,760 KB |
testcase_23 | AC | 79 ms
37,820 KB |
testcase_24 | AC | 1,268 ms
60,724 KB |
testcase_25 | AC | 1,269 ms
56,492 KB |
testcase_26 | AC | 907 ms
57,964 KB |
testcase_27 | AC | 1,436 ms
60,700 KB |
testcase_28 | AC | 947 ms
58,488 KB |
testcase_29 | AC | 1,625 ms
62,776 KB |
testcase_30 | AC | 870 ms
58,164 KB |
testcase_31 | AC | 650 ms
51,344 KB |
testcase_32 | AC | 1,545 ms
61,644 KB |
testcase_33 | AC | 950 ms
57,864 KB |
testcase_34 | AC | 1,226 ms
61,496 KB |
testcase_35 | AC | 1,499 ms
64,948 KB |
testcase_36 | AC | 371 ms
46,208 KB |
testcase_37 | AC | 736 ms
53,924 KB |
testcase_38 | AC | 1,623 ms
62,632 KB |
testcase_39 | AC | 1,324 ms
60,888 KB |
testcase_40 | AC | 1,271 ms
62,344 KB |
testcase_41 | AC | 306 ms
42,848 KB |
testcase_42 | AC | 1,415 ms
63,520 KB |
testcase_43 | AC | 1,588 ms
62,656 KB |
testcase_44 | AC | 1,597 ms
64,512 KB |
testcase_45 | AC | 1,705 ms
64,324 KB |
testcase_46 | AC | 1,673 ms
64,132 KB |
testcase_47 | AC | 1,802 ms
64,428 KB |
testcase_48 | AC | 1,729 ms
63,880 KB |
testcase_49 | AC | 1,401 ms
62,704 KB |
testcase_50 | AC | 1,681 ms
64,672 KB |
testcase_51 | AC | 1,710 ms
64,608 KB |
testcase_52 | AC | 1,762 ms
64,208 KB |
testcase_53 | AC | 1,793 ms
64,208 KB |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int d = sc.nextInt(); long[] arr = new long[n]; ArrayList<Long> a = new ArrayList<Long>(); for(int i = 0; i < n; i++){ long b = sc.nextLong(); arr[i] = b; a.add(b); } Collections.sort(a,Comparator.reverseOrder()); for(int i = 0; i < n; i++){ System.out.println(n-beamSearch(arr[i]-d,a)); } } public static int beamSearch(long d, ArrayList<Long> arr){ int left = 0; int right = arr.size(); while(right - left > 1){ int mid = (right + left) / 2; if(arr.get(mid) > d){ left = mid; }else{ right = mid; } } return right; } } class FastScanner { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String[] nextArray(int n) { String[] a = new String[n]; for (int i = 0; i < n; i++) a[i] = next(); return a; } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } }