結果
問題 | No.1922 Separate and Attach |
ユーザー | tenten |
提出日時 | 2023-06-29 16:22:11 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 296 ms / 2,000 ms |
コード長 | 2,194 bytes |
コンパイル時間 | 2,293 ms |
コンパイル使用メモリ | 84,804 KB |
実行使用メモリ | 64,228 KB |
最終ジャッジ日時 | 2024-07-06 07:05:11 |
合計ジャッジ時間 | 12,617 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
50,052 KB |
testcase_01 | AC | 45 ms
50,452 KB |
testcase_02 | AC | 45 ms
50,292 KB |
testcase_03 | AC | 44 ms
50,432 KB |
testcase_04 | AC | 45 ms
50,064 KB |
testcase_05 | AC | 44 ms
49,996 KB |
testcase_06 | AC | 45 ms
50,160 KB |
testcase_07 | AC | 45 ms
50,500 KB |
testcase_08 | AC | 44 ms
50,368 KB |
testcase_09 | AC | 45 ms
50,236 KB |
testcase_10 | AC | 45 ms
50,228 KB |
testcase_11 | AC | 45 ms
50,284 KB |
testcase_12 | AC | 44 ms
50,136 KB |
testcase_13 | AC | 45 ms
50,420 KB |
testcase_14 | AC | 46 ms
50,288 KB |
testcase_15 | AC | 45 ms
50,192 KB |
testcase_16 | AC | 44 ms
50,272 KB |
testcase_17 | AC | 44 ms
50,296 KB |
testcase_18 | AC | 44 ms
50,240 KB |
testcase_19 | AC | 44 ms
50,384 KB |
testcase_20 | AC | 45 ms
50,552 KB |
testcase_21 | AC | 46 ms
50,268 KB |
testcase_22 | AC | 46 ms
50,136 KB |
testcase_23 | AC | 46 ms
50,384 KB |
testcase_24 | AC | 45 ms
50,024 KB |
testcase_25 | AC | 45 ms
50,136 KB |
testcase_26 | AC | 45 ms
50,252 KB |
testcase_27 | AC | 51 ms
50,464 KB |
testcase_28 | AC | 78 ms
51,268 KB |
testcase_29 | AC | 111 ms
55,108 KB |
testcase_30 | AC | 232 ms
60,948 KB |
testcase_31 | AC | 230 ms
60,864 KB |
testcase_32 | AC | 261 ms
63,196 KB |
testcase_33 | AC | 270 ms
62,816 KB |
testcase_34 | AC | 284 ms
63,220 KB |
testcase_35 | AC | 291 ms
63,528 KB |
testcase_36 | AC | 278 ms
63,008 KB |
testcase_37 | AC | 273 ms
63,108 KB |
testcase_38 | AC | 279 ms
62,976 KB |
testcase_39 | AC | 296 ms
64,020 KB |
testcase_40 | AC | 296 ms
63,892 KB |
testcase_41 | AC | 278 ms
63,152 KB |
testcase_42 | AC | 262 ms
63,052 KB |
testcase_43 | AC | 262 ms
62,980 KB |
testcase_44 | AC | 271 ms
63,272 KB |
testcase_45 | AC | 285 ms
63,252 KB |
testcase_46 | AC | 264 ms
62,920 KB |
testcase_47 | AC | 268 ms
63,176 KB |
testcase_48 | AC | 275 ms
64,220 KB |
testcase_49 | AC | 282 ms
64,228 KB |
testcase_50 | AC | 279 ms
62,728 KB |
testcase_51 | AC | 282 ms
62,892 KB |
testcase_52 | AC | 46 ms
50,508 KB |
testcase_53 | AC | 45 ms
50,292 KB |
testcase_54 | AC | 45 ms
50,452 KB |
testcase_55 | AC | 46 ms
50,116 KB |
testcase_56 | AC | 45 ms
49,920 KB |
testcase_57 | AC | 45 ms
50,396 KB |
ソースコード
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(); } }