結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー | 37zigen |
提出日時 | 2018-12-07 02:40:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 837 ms / 2,000 ms |
コード長 | 3,450 bytes |
コンパイル時間 | 2,358 ms |
コンパイル使用メモリ | 79,436 KB |
実行使用メモリ | 54,684 KB |
最終ジャッジ日時 | 2024-09-14 03:11:22 |
合計ジャッジ時間 | 16,816 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,044 KB |
testcase_01 | AC | 51 ms
36,784 KB |
testcase_02 | AC | 51 ms
36,760 KB |
testcase_03 | AC | 51 ms
36,900 KB |
testcase_04 | AC | 51 ms
36,732 KB |
testcase_05 | AC | 51 ms
37,016 KB |
testcase_06 | AC | 50 ms
36,888 KB |
testcase_07 | AC | 51 ms
36,520 KB |
testcase_08 | AC | 52 ms
36,944 KB |
testcase_09 | AC | 52 ms
36,636 KB |
testcase_10 | AC | 51 ms
36,984 KB |
testcase_11 | AC | 51 ms
36,928 KB |
testcase_12 | AC | 53 ms
36,560 KB |
testcase_13 | AC | 51 ms
36,992 KB |
testcase_14 | AC | 52 ms
36,980 KB |
testcase_15 | AC | 54 ms
37,044 KB |
testcase_16 | AC | 54 ms
36,520 KB |
testcase_17 | AC | 52 ms
36,644 KB |
testcase_18 | AC | 53 ms
37,084 KB |
testcase_19 | AC | 52 ms
36,792 KB |
testcase_20 | AC | 52 ms
36,888 KB |
testcase_21 | AC | 53 ms
36,984 KB |
testcase_22 | AC | 52 ms
37,044 KB |
testcase_23 | AC | 52 ms
36,984 KB |
testcase_24 | AC | 52 ms
36,964 KB |
testcase_25 | AC | 53 ms
36,940 KB |
testcase_26 | AC | 53 ms
36,784 KB |
testcase_27 | AC | 52 ms
36,480 KB |
testcase_28 | AC | 53 ms
36,836 KB |
testcase_29 | AC | 54 ms
36,784 KB |
testcase_30 | AC | 53 ms
37,012 KB |
testcase_31 | AC | 53 ms
36,992 KB |
testcase_32 | AC | 53 ms
37,004 KB |
testcase_33 | AC | 128 ms
39,212 KB |
testcase_34 | AC | 79 ms
37,744 KB |
testcase_35 | AC | 92 ms
38,652 KB |
testcase_36 | AC | 127 ms
39,328 KB |
testcase_37 | AC | 81 ms
37,696 KB |
testcase_38 | AC | 141 ms
39,840 KB |
testcase_39 | AC | 81 ms
37,524 KB |
testcase_40 | AC | 118 ms
39,068 KB |
testcase_41 | AC | 111 ms
39,064 KB |
testcase_42 | AC | 136 ms
39,620 KB |
testcase_43 | AC | 130 ms
39,448 KB |
testcase_44 | AC | 416 ms
48,896 KB |
testcase_45 | AC | 407 ms
48,596 KB |
testcase_46 | AC | 392 ms
48,780 KB |
testcase_47 | AC | 374 ms
48,424 KB |
testcase_48 | AC | 385 ms
48,460 KB |
testcase_49 | AC | 144 ms
39,464 KB |
testcase_50 | AC | 135 ms
39,452 KB |
testcase_51 | AC | 135 ms
39,416 KB |
testcase_52 | AC | 136 ms
39,596 KB |
testcase_53 | AC | 387 ms
48,724 KB |
testcase_54 | AC | 390 ms
48,844 KB |
testcase_55 | AC | 387 ms
48,624 KB |
testcase_56 | AC | 375 ms
48,688 KB |
testcase_57 | AC | 370 ms
48,924 KB |
testcase_58 | AC | 383 ms
48,524 KB |
testcase_59 | AC | 386 ms
48,548 KB |
testcase_60 | AC | 359 ms
48,720 KB |
testcase_61 | AC | 406 ms
48,648 KB |
testcase_62 | AC | 401 ms
48,644 KB |
testcase_63 | AC | 809 ms
54,384 KB |
testcase_64 | AC | 837 ms
54,552 KB |
testcase_65 | AC | 395 ms
49,076 KB |
testcase_66 | AC | 794 ms
54,684 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(); int N = sc.nextInt(); int[] P = new int[N]; int[] T = new int[N]; int[] R = new int[N]; int[][] a = new int[N][]; for (int i = 0; i < N; ++i) { P[i] = sc.nextInt(); T[i] = sc.nextInt(); R[i] = sc.nextInt(); a[i] = new int[] { P[i], T[i], R[i], i }; } Arrays.sort(a, new Comparator<int[]>() { public int compare(int[] o1, int[] o2) { if (o1[0] != o2[0]) { return -Integer.compare(o1[0], o2[0]); } else if (o1[1] != o2[1]) { return -Integer.compare(o1[1], o2[1]); } else { return -Integer.compare(o1[2], o2[2]); } } }); boolean[] ok = new boolean[N]; Arrays.fill(ok, true); RMQ rmq = new RMQ(10000 + 1); for (int i = 0; i < N; ++i) { if (rmq.query(a[i][1], 10000 + 1) >= a[i][2]) { ok[a[i][3]] = false; } rmq.update(a[i][1], a[i][2]); } for (int i = 0; i < N; ++i) { if (ok[i]) System.out.println(i + 1); } } class RMQ { int n; int[] v; public RMQ(int n_) { n = 1; while (n < n_) n *= 2; v = new int[2 * n - 1]; Arrays.fill(v, -1); } void update(int k, int val) { k += n - 1; v[k] = Math.max(v[k], val); while (k > 0) { k = (k - 1) / 2; v[k] = Math.max(v[2 * k + 1], v[2 * k + 2]); } } int query(int a, int b) { return query(a, b, 0, n, 0); } int query(int a, int b, int l, int r, int k) { if (a <= l && r <= b) return v[k]; else if (b <= l || r <= a) return -1; else { int vl = query(a, b, l, (l + r) / 2, 2 * k + 1); int vr = query(a, b, (l + r) / 2, r, 2 * k + 2); return Math.max(vl, vr); } } } void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } } class Scanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int) nextLong(); } }