結果

問題 No.711 競技レーティング単調増加
ユーザー 37zigen37zigen
提出日時 2018-06-30 00:56:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,591 bytes
コンパイル時間 2,938 ms
コンパイル使用メモリ 76,688 KB
実行使用メモリ 71,696 KB
最終ジャッジ日時 2023-09-13 16:00:25
合計ジャッジ時間 26,590 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,996 KB
testcase_01 AC 121 ms
55,836 KB
testcase_02 AC 123 ms
55,992 KB
testcase_03 AC 131 ms
55,880 KB
testcase_04 AC 129 ms
56,008 KB
testcase_05 AC 130 ms
56,192 KB
testcase_06 AC 131 ms
56,204 KB
testcase_07 AC 132 ms
55,892 KB
testcase_08 AC 133 ms
56,260 KB
testcase_09 AC 132 ms
55,440 KB
testcase_10 AC 132 ms
56,328 KB
testcase_11 AC 131 ms
55,908 KB
testcase_12 AC 132 ms
56,080 KB
testcase_13 AC 129 ms
56,284 KB
testcase_14 AC 130 ms
55,620 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 131 ms
56,192 KB
testcase_18 AC 756 ms
66,968 KB
testcase_19 AC 782 ms
67,500 KB
testcase_20 AC 810 ms
67,008 KB
testcase_21 AC 812 ms
64,984 KB
testcase_22 AC 785 ms
66,704 KB
testcase_23 AC 819 ms
65,124 KB
testcase_24 AC 841 ms
64,884 KB
testcase_25 AC 745 ms
65,096 KB
testcase_26 AC 808 ms
65,212 KB
testcase_27 AC 756 ms
67,248 KB
testcase_28 AC 595 ms
63,764 KB
testcase_29 AC 635 ms
64,860 KB
testcase_30 AC 875 ms
71,596 KB
testcase_31 AC 990 ms
69,552 KB
testcase_32 AC 1,060 ms
68,992 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 595 ms
64,780 KB
testcase_37 AC 833 ms
70,464 KB
testcase_38 AC 713 ms
69,096 KB
testcase_39 AC 541 ms
60,744 KB
testcase_40 WA -
testcase_41 AC 119 ms
56,180 KB
testcase_42 WA -
testcase_43 AC 628 ms
66,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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) {
			int idx = Arrays.binarySearch(dp, 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));
	}

}
0