結果

問題 No.711 競技レーティング単調増加
ユーザー 37zigen37zigen
提出日時 2018-06-30 00:17:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,489 bytes
コンパイル時間 3,094 ms
コンパイル使用メモリ 76,396 KB
実行使用メモリ 73,596 KB
最終ジャッジ日時 2023-09-13 15:55:18
合計ジャッジ時間 28,945 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,044 KB
testcase_01 AC 127 ms
55,852 KB
testcase_02 AC 124 ms
55,728 KB
testcase_03 WA -
testcase_04 AC 130 ms
55,848 KB
testcase_05 WA -
testcase_06 AC 131 ms
55,924 KB
testcase_07 AC 132 ms
55,756 KB
testcase_08 AC 139 ms
55,756 KB
testcase_09 AC 136 ms
56,044 KB
testcase_10 AC 133 ms
55,644 KB
testcase_11 AC 132 ms
56,296 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 133 ms
56,044 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 897 ms
69,328 KB
testcase_31 AC 1,017 ms
68,772 KB
testcase_32 AC 1,062 ms
69,192 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 687 ms
70,328 KB
testcase_37 AC 854 ms
71,320 KB
testcase_38 AC 774 ms
69,544 KB
testcase_39 AC 562 ms
61,312 KB
testcase_40 WA -
testcase_41 AC 123 ms
56,024 KB
testcase_42 WA -
testcase_43 AC 646 ms
64,676 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[] A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt() - 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, A[i]);
			if (idx >= 0) {
				dp[idx + 1] = A[i];
			} else {
				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));
	}

}
0