結果

問題 No.610 区間賞(Section Award)
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-10 00:08:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 440 ms / 2,000 ms
コード長 2,034 bytes
コンパイル時間 2,477 ms
コンパイル使用メモリ 77,716 KB
実行使用メモリ 50,344 KB
最終ジャッジ日時 2024-05-07 12:50:19
合計ジャッジ時間 12,902 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,852 KB
testcase_01 AC 54 ms
36,840 KB
testcase_02 AC 53 ms
36,852 KB
testcase_03 AC 53 ms
37,200 KB
testcase_04 AC 54 ms
37,020 KB
testcase_05 AC 56 ms
37,236 KB
testcase_06 AC 64 ms
38,396 KB
testcase_07 AC 56 ms
37,236 KB
testcase_08 AC 77 ms
38,268 KB
testcase_09 AC 57 ms
37,388 KB
testcase_10 AC 64 ms
37,996 KB
testcase_11 AC 64 ms
38,052 KB
testcase_12 AC 54 ms
37,504 KB
testcase_13 AC 67 ms
38,536 KB
testcase_14 AC 67 ms
38,376 KB
testcase_15 AC 65 ms
37,608 KB
testcase_16 AC 62 ms
38,016 KB
testcase_17 AC 61 ms
36,976 KB
testcase_18 AC 56 ms
37,160 KB
testcase_19 AC 148 ms
42,468 KB
testcase_20 AC 285 ms
46,872 KB
testcase_21 AC 117 ms
41,428 KB
testcase_22 AC 231 ms
45,396 KB
testcase_23 AC 117 ms
40,328 KB
testcase_24 AC 153 ms
43,340 KB
testcase_25 AC 110 ms
39,684 KB
testcase_26 AC 198 ms
43,884 KB
testcase_27 AC 258 ms
46,808 KB
testcase_28 AC 272 ms
46,912 KB
testcase_29 AC 225 ms
45,324 KB
testcase_30 AC 241 ms
46,064 KB
testcase_31 AC 186 ms
43,904 KB
testcase_32 AC 287 ms
47,212 KB
testcase_33 AC 123 ms
41,056 KB
testcase_34 AC 257 ms
47,208 KB
testcase_35 AC 191 ms
45,248 KB
testcase_36 AC 275 ms
47,160 KB
testcase_37 AC 263 ms
46,528 KB
testcase_38 AC 146 ms
42,236 KB
testcase_39 AC 281 ms
46,804 KB
testcase_40 AC 283 ms
46,940 KB
testcase_41 AC 263 ms
46,972 KB
testcase_42 AC 283 ms
47,108 KB
testcase_43 AC 268 ms
46,908 KB
testcase_44 AC 385 ms
47,924 KB
testcase_45 AC 425 ms
47,668 KB
testcase_46 AC 440 ms
50,344 KB
testcase_47 AC 232 ms
47,228 KB
testcase_48 AC 237 ms
47,184 KB
testcase_49 AC 249 ms
47,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int[]a=new int[n],b=new int[n];
        for(int i=0;i<n;++i)a[i]=sc.nextInt()-1;
        for(int i=0;i<n;++i)b[i]=sc.nextInt()-1;
        int[]c=new int[n],d=new int[n];
        for(int i=0;i<n;++i)c[b[i]]=i;
        for(int i=0;i<n;++i)d[i]=c[a[i]];
        int p=0;
        int[]e=new int[n];
        int m=n+1;
        for(int i=n-1;i>=0;--i){
            if(d[i]<m)
                e[p++]=a[i];
            m=Math.min(m,d[i]);
        }
        Arrays.sort(e,0,p);
        for(int i=0;i<p;++i)
            out.println(e[i]+1);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
0