結果

問題 No.1922 Separate and Attach
ユーザー tentententen
提出日時 2023-06-29 16:22:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 2,194 bytes
コンパイル時間 4,366 ms
コンパイル使用メモリ 80,856 KB
実行使用メモリ 64,316 KB
最終ジャッジ日時 2023-09-20 11:40:46
合計ジャッジ時間 15,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,432 KB
testcase_01 AC 44 ms
49,336 KB
testcase_02 AC 44 ms
49,344 KB
testcase_03 AC 46 ms
49,348 KB
testcase_04 AC 46 ms
49,220 KB
testcase_05 AC 45 ms
49,508 KB
testcase_06 AC 45 ms
49,268 KB
testcase_07 AC 45 ms
49,456 KB
testcase_08 AC 45 ms
49,456 KB
testcase_09 AC 45 ms
49,360 KB
testcase_10 AC 45 ms
49,552 KB
testcase_11 AC 45 ms
49,452 KB
testcase_12 AC 44 ms
49,308 KB
testcase_13 AC 45 ms
49,388 KB
testcase_14 AC 46 ms
49,336 KB
testcase_15 AC 45 ms
49,336 KB
testcase_16 AC 44 ms
49,456 KB
testcase_17 AC 44 ms
49,452 KB
testcase_18 AC 45 ms
49,396 KB
testcase_19 AC 46 ms
49,292 KB
testcase_20 AC 44 ms
49,396 KB
testcase_21 AC 45 ms
49,496 KB
testcase_22 AC 44 ms
49,364 KB
testcase_23 AC 44 ms
49,256 KB
testcase_24 AC 44 ms
47,284 KB
testcase_25 AC 47 ms
49,332 KB
testcase_26 AC 47 ms
49,740 KB
testcase_27 AC 57 ms
50,432 KB
testcase_28 AC 75 ms
51,632 KB
testcase_29 AC 140 ms
54,820 KB
testcase_30 AC 256 ms
60,584 KB
testcase_31 AC 253 ms
60,176 KB
testcase_32 AC 327 ms
63,580 KB
testcase_33 AC 322 ms
63,488 KB
testcase_34 AC 299 ms
63,780 KB
testcase_35 AC 310 ms
63,568 KB
testcase_36 AC 326 ms
63,444 KB
testcase_37 AC 326 ms
63,412 KB
testcase_38 AC 337 ms
64,172 KB
testcase_39 AC 350 ms
63,712 KB
testcase_40 AC 341 ms
63,584 KB
testcase_41 AC 351 ms
63,884 KB
testcase_42 AC 313 ms
63,440 KB
testcase_43 AC 307 ms
63,140 KB
testcase_44 AC 319 ms
63,412 KB
testcase_45 AC 331 ms
63,868 KB
testcase_46 AC 318 ms
63,524 KB
testcase_47 AC 336 ms
64,256 KB
testcase_48 AC 307 ms
63,040 KB
testcase_49 AC 345 ms
63,660 KB
testcase_50 AC 318 ms
63,156 KB
testcase_51 AC 332 ms
64,316 KB
testcase_52 AC 45 ms
49,524 KB
testcase_53 AC 44 ms
49,344 KB
testcase_54 AC 44 ms
49,268 KB
testcase_55 AC 44 ms
49,268 KB
testcase_56 AC 44 ms
49,340 KB
testcase_57 AC 46 ms
49,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            map.put(sc.nextInt(), i);
        }
        int[] places = new int[n];
        for (int i = 0; i < n; i++) {
            places[map.get(values[i])] = i;
        }
        int current = -1;
        int count = 1;
        for (int i = 0; i < n; i++) {
            if (current > places[i]) {
                count++;
            }
            current = places[i];
        }
        int ans = 0;
        int v = 1;
        while (count > v) {
            v *= 2;
            ans++;
        }
        System.out.println(ans);
    }
}

class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0