結果
問題 | No.711 競技レーティング単調増加 |
ユーザー | 37zigen |
提出日時 | 2018-06-30 00:19:47 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,522 bytes |
コンパイル時間 | 2,308 ms |
コンパイル使用メモリ | 76,116 KB |
実行使用メモリ | 73,768 KB |
最終ジャッジ日時 | 2023-09-13 15:55:57 |
合計ジャッジ時間 | 30,532 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
55,620 KB |
testcase_01 | AC | 127 ms
55,620 KB |
testcase_02 | AC | 127 ms
55,608 KB |
testcase_03 | WA | - |
testcase_04 | AC | 135 ms
55,968 KB |
testcase_05 | WA | - |
testcase_06 | AC | 137 ms
55,828 KB |
testcase_07 | AC | 137 ms
55,404 KB |
testcase_08 | AC | 136 ms
55,680 KB |
testcase_09 | AC | 136 ms
55,792 KB |
testcase_10 | AC | 137 ms
55,884 KB |
testcase_11 | AC | 134 ms
55,956 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 134 ms
56,060 KB |
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 | AC | 903 ms
71,272 KB |
testcase_31 | AC | 1,099 ms
71,824 KB |
testcase_32 | AC | 1,106 ms
73,264 KB |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 707 ms
71,852 KB |
testcase_37 | AC | 869 ms
70,860 KB |
testcase_38 | AC | 770 ms
71,276 KB |
testcase_39 | AC | 565 ms
63,420 KB |
testcase_40 | WA | - |
testcase_41 | AC | 121 ms
55,668 KB |
testcase_42 | WA | - |
testcase_43 | AC | 651 ms
69,500 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(); long[] A = new long[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextLong() - i + N; } 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, (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); } long[] shrink(long[] a) { int n = a.length; long[] ret = new long[n]; long[][] x = new long[n][2]; for (int i = 0; i < n; ++i) { x[i][0] = i; x[i][1] = a[i]; } Arrays.sort(x, new Comparator<long[]>() { @Override public int compare(long[] o1, long[] o2) { return Long.compare(o1[1], o2[1]); } }); int p = 1; 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)); } }