結果

問題 No.711 競技レーティング単調増加
ユーザー Medo NasserMedo Nasser
提出日時 2018-07-05 14:52:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,340 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 77,112 KB
実行使用メモリ 76,148 KB
最終ジャッジ日時 2023-09-13 17:47:30
合計ジャッジ時間 17,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,360 KB
testcase_01 AC 43 ms
49,384 KB
testcase_02 AC 42 ms
49,408 KB
testcase_03 AC 44 ms
49,392 KB
testcase_04 AC 45 ms
49,356 KB
testcase_05 WA -
testcase_06 AC 45 ms
49,572 KB
testcase_07 AC 45 ms
49,392 KB
testcase_08 AC 44 ms
49,412 KB
testcase_09 AC 43 ms
49,316 KB
testcase_10 AC 45 ms
49,880 KB
testcase_11 AC 45 ms
49,520 KB
testcase_12 AC 44 ms
49,360 KB
testcase_13 AC 44 ms
49,576 KB
testcase_14 AC 44 ms
49,360 KB
testcase_15 AC 45 ms
49,388 KB
testcase_16 AC 46 ms
49,516 KB
testcase_17 AC 46 ms
49,432 KB
testcase_18 AC 548 ms
74,592 KB
testcase_19 AC 523 ms
74,312 KB
testcase_20 AC 516 ms
71,084 KB
testcase_21 AC 527 ms
70,852 KB
testcase_22 AC 538 ms
74,560 KB
testcase_23 AC 585 ms
73,824 KB
testcase_24 AC 551 ms
73,836 KB
testcase_25 AC 513 ms
71,928 KB
testcase_26 WA -
testcase_27 AC 510 ms
72,340 KB
testcase_28 AC 497 ms
68,076 KB
testcase_29 AC 452 ms
66,972 KB
testcase_30 AC 514 ms
68,808 KB
testcase_31 AC 502 ms
66,808 KB
testcase_32 AC 542 ms
69,624 KB
testcase_33 AC 415 ms
62,544 KB
testcase_34 AC 393 ms
62,856 KB
testcase_35 AC 414 ms
63,140 KB
testcase_36 AC 413 ms
76,148 KB
testcase_37 AC 506 ms
75,488 KB
testcase_38 AC 434 ms
70,860 KB
testcase_39 AC 317 ms
62,912 KB
testcase_40 AC 318 ms
60,772 KB
testcase_41 AC 43 ms
49,396 KB
testcase_42 AC 206 ms
56,092 KB
testcase_43 AC 403 ms
66,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main
{
	static int bit[];
	static void update(int ind,int delta) {
		while (ind < bit.length) {
			bit[ind] = Math.max(bit[ind], delta);
			ind += ind & -ind;
		}
	}
	static int get(int ind) {
		int res = 0;
		while (ind > 0) {
			res = Math.max(res, bit[ind]);
			ind -= ind & -ind;
		}
		return res;
	}
	public static void main(String[]args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean bad[] = new boolean[n];
		TreeMap<Integer,Integer> cord = new TreeMap();
		int arr[] = new int[n];
		for (int i = 0 ; i < n ; ++i) {
			arr[i] = sc.nextInt() - i;
			if (arr[i] < 0) {
				bad[i] = true;
			}
			cord.put(arr[i], 0);
		}

		int maxVal = 1;
		for (Map.Entry<Integer,Integer> x : cord.entrySet()) {
			x.setValue(maxVal++);
		}
		int lis = 0;
		maxVal++;
		bit = new int[maxVal + 1];
		for (int i = 0 ; i < n; ++i) {
			arr[i] = cord.get(arr[i]);
		}
		for (int i = 0 ; i < n ; ++i) {
			if (bad[i]) {
				continue;
			}
			int cur = get(arr[i]) + 1;
			lis = Math.max(lis, cur);
			update(arr[i],cur);
		}

		System.out.println(n - lis);
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}
0