結果
問題 | No.711 競技レーティング単調増加 |
ユーザー | Medo Nasser |
提出日時 | 2018-07-05 14:56:06 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 598 ms / 2,000 ms |
コード長 | 2,358 bytes |
コンパイル時間 | 2,747 ms |
コンパイル使用メモリ | 76,224 KB |
実行使用メモリ | 76,188 KB |
最終ジャッジ日時 | 2023-09-13 17:53:46 |
合計ジャッジ時間 | 17,945 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
49,268 KB |
testcase_01 | AC | 42 ms
49,380 KB |
testcase_02 | AC | 42 ms
49,520 KB |
testcase_03 | AC | 45 ms
49,432 KB |
testcase_04 | AC | 45 ms
49,496 KB |
testcase_05 | AC | 45 ms
49,420 KB |
testcase_06 | AC | 46 ms
49,336 KB |
testcase_07 | AC | 46 ms
49,448 KB |
testcase_08 | AC | 44 ms
49,324 KB |
testcase_09 | AC | 45 ms
49,328 KB |
testcase_10 | AC | 46 ms
49,380 KB |
testcase_11 | AC | 44 ms
49,560 KB |
testcase_12 | AC | 45 ms
49,420 KB |
testcase_13 | AC | 45 ms
49,248 KB |
testcase_14 | AC | 43 ms
49,248 KB |
testcase_15 | AC | 48 ms
49,424 KB |
testcase_16 | AC | 46 ms
49,348 KB |
testcase_17 | AC | 46 ms
49,528 KB |
testcase_18 | AC | 536 ms
73,980 KB |
testcase_19 | AC | 539 ms
74,388 KB |
testcase_20 | AC | 522 ms
70,416 KB |
testcase_21 | AC | 538 ms
70,728 KB |
testcase_22 | AC | 544 ms
74,312 KB |
testcase_23 | AC | 598 ms
74,092 KB |
testcase_24 | AC | 568 ms
73,264 KB |
testcase_25 | AC | 504 ms
72,088 KB |
testcase_26 | AC | 529 ms
70,476 KB |
testcase_27 | AC | 525 ms
72,048 KB |
testcase_28 | AC | 466 ms
66,552 KB |
testcase_29 | AC | 441 ms
66,952 KB |
testcase_30 | AC | 518 ms
68,524 KB |
testcase_31 | AC | 527 ms
67,172 KB |
testcase_32 | AC | 522 ms
69,380 KB |
testcase_33 | AC | 418 ms
63,504 KB |
testcase_34 | AC | 391 ms
62,616 KB |
testcase_35 | AC | 431 ms
62,956 KB |
testcase_36 | AC | 450 ms
76,188 KB |
testcase_37 | AC | 481 ms
75,116 KB |
testcase_38 | AC | 434 ms
68,368 KB |
testcase_39 | AC | 312 ms
63,104 KB |
testcase_40 | AC | 321 ms
60,860 KB |
testcase_41 | AC | 45 ms
49,440 KB |
testcase_42 | AC | 221 ms
55,984 KB |
testcase_43 | AC | 397 ms
65,688 KB |
ソースコード
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(); if (arr[i] - i <= 0) { bad[i] = true; } arr[i] -= 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) { 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(); } } }