結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,480 KB
testcase_01 AC 44 ms
49,964 KB
testcase_02 AC 44 ms
49,732 KB
testcase_03 WA -
testcase_04 AC 47 ms
49,820 KB
testcase_05 WA -
testcase_06 AC 46 ms
49,444 KB
testcase_07 AC 47 ms
49,496 KB
testcase_08 AC 46 ms
49,620 KB
testcase_09 AC 46 ms
49,520 KB
testcase_10 AC 47 ms
49,452 KB
testcase_11 AC 47 ms
49,468 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 46 ms
49,528 KB
testcase_16 AC 47 ms
49,512 KB
testcase_17 AC 48 ms
47,552 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 539 ms
68,532 KB
testcase_31 AC 524 ms
66,800 KB
testcase_32 AC 532 ms
69,160 KB
testcase_33 AC 419 ms
62,624 KB
testcase_34 AC 414 ms
65,864 KB
testcase_35 AC 395 ms
62,612 KB
testcase_36 AC 432 ms
76,656 KB
testcase_37 AC 512 ms
75,276 KB
testcase_38 AC 430 ms
70,388 KB
testcase_39 AC 339 ms
62,596 KB
testcase_40 AC 334 ms
58,808 KB
testcase_41 AC 44 ms
49,968 KB
testcase_42 AC 227 ms
56,424 KB
testcase_43 AC 414 ms
65,568 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);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		TreeMap<Integer,Integer> cord = new TreeMap();
		int arr[] = new int[n];
		for (int i = 0 ; i < n ; ++i) {
			arr[i] = sc.nextInt() - i;
			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) {
			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