結果
問題 | No.711 競技レーティング単調増加 |
ユーザー | 37zigen |
提出日時 | 2018-06-29 23:20:44 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,450 bytes |
コンパイル時間 | 2,720 ms |
コンパイル使用メモリ | 77,176 KB |
実行使用メモリ | 72,336 KB |
最終ジャッジ日時 | 2023-09-13 15:41:12 |
合計ジャッジ時間 | 28,725 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
55,896 KB |
testcase_01 | AC | 125 ms
56,044 KB |
testcase_02 | AC | 122 ms
55,872 KB |
testcase_03 | WA | - |
testcase_04 | AC | 133 ms
56,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 133 ms
55,792 KB |
testcase_07 | WA | - |
testcase_08 | AC | 139 ms
55,852 KB |
testcase_09 | AC | 133 ms
56,472 KB |
testcase_10 | AC | 132 ms
55,856 KB |
testcase_11 | AC | 133 ms
55,524 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 704 ms
69,796 KB |
testcase_37 | AC | 835 ms
71,560 KB |
testcase_38 | AC | 764 ms
69,388 KB |
testcase_39 | AC | 561 ms
61,180 KB |
testcase_40 | AC | 707 ms
63,664 KB |
testcase_41 | AC | 124 ms
55,912 KB |
testcase_42 | AC | 566 ms
62,308 KB |
testcase_43 | AC | 659 ms
67,428 KB |
ソースコード
import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int N = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); } A = shrink(A); int[] dp = new int[N + 1]; Arrays.fill(dp, Integer.MAX_VALUE / 3); for (int i = 0; i < N; ++i) { int idx = Arrays.binarySearch(dp, A[i]); if (idx >= 0) continue; idx = -(idx + 1); dp[idx] = A[i]; } int ans = 0; for (int i = 0; i < dp.length; ++i) { if (dp[i] == Integer.MAX_VALUE / 3) continue; ans = Math.max(ans, i + 1); } System.out.println(N - ans); } int[] shrink(int[] a) { int n = a.length; int[] ret = new int[n]; int[][] x = new int[n][2]; for (int i = 0; i < n; ++i) { x[i][0] = i; x[i][1] = a[i]; } Arrays.sort(x, new Comparator<int[]>() { @Override public int compare(int[] o1, int[] o2) { return Integer.compare(o1[1], o2[1]); } }); int p = 1; for (int i = 0; i < n; ++i) { ret[x[i][0]] = p; if (i + 1 < n && x[i][1] != x[i + 1][1]) ++p; } return ret; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }