結果
問題 | No.711 競技レーティング単調増加 |
ユーザー | 37zigen |
提出日時 | 2018-06-30 00:54:03 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,627 bytes |
コンパイル時間 | 3,385 ms |
コンパイル使用メモリ | 76,592 KB |
実行使用メモリ | 74,264 KB |
最終ジャッジ日時 | 2023-09-13 16:01:40 |
合計ジャッジ時間 | 26,745 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 122 ms
55,988 KB |
testcase_02 | WA | - |
testcase_03 | AC | 131 ms
55,736 KB |
testcase_04 | WA | - |
testcase_05 | AC | 132 ms
56,072 KB |
testcase_06 | AC | 130 ms
55,980 KB |
testcase_07 | AC | 130 ms
55,744 KB |
testcase_08 | AC | 130 ms
55,988 KB |
testcase_09 | AC | 132 ms
55,632 KB |
testcase_10 | AC | 130 ms
55,644 KB |
testcase_11 | WA | - |
testcase_12 | AC | 131 ms
55,900 KB |
testcase_13 | AC | 129 ms
55,732 KB |
testcase_14 | AC | 129 ms
55,972 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 132 ms
55,704 KB |
testcase_18 | AC | 820 ms
67,168 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 815 ms
65,096 KB |
testcase_22 | WA | - |
testcase_23 | AC | 825 ms
65,084 KB |
testcase_24 | AC | 816 ms
66,876 KB |
testcase_25 | AC | 745 ms
65,616 KB |
testcase_26 | AC | 801 ms
64,848 KB |
testcase_27 | AC | 742 ms
67,180 KB |
testcase_28 | AC | 590 ms
64,096 KB |
testcase_29 | AC | 628 ms
64,780 KB |
testcase_30 | AC | 880 ms
69,924 KB |
testcase_31 | AC | 1,027 ms
71,708 KB |
testcase_32 | AC | 1,059 ms
68,964 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 819 ms
72,776 KB |
testcase_38 | AC | 743 ms
74,264 KB |
testcase_39 | AC | 531 ms
60,512 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
ソースコード
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 p = 0; int[] A = new int[N]; for (int i = 0; i < N; ++i) { int a = sc.nextInt() - i; if (a <= 0) continue; A[p++] = a; } A=Arrays.copyOf(A, p); A = shrink(A); int[] dp = new int[N + 1]; Arrays.fill(dp, Integer.MAX_VALUE / 3); for (int i = 0; i < A.length; ++i) { if (A[i] <= 0) continue; int idx = Arrays.binarySearch(dp, (int) A[i]); if (idx >= 0) { dp[idx + 1] = (int) A[i]; } else { idx = -(idx + 1); dp[idx] = (int) 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 Long.compare(o1[1], o2[1]); } }); int p = 0; for (int i = 0; i < n; ++i) { ret[(int) 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)); } }