結果

問題 No.610 区間賞(Section Award)
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-10 00:08:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 2,034 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 74,828 KB
実行使用メモリ 61,560 KB
最終ジャッジ日時 2023-08-20 05:28:32
合計ジャッジ時間 13,047 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,520 KB
testcase_01 AC 43 ms
49,436 KB
testcase_02 AC 42 ms
49,664 KB
testcase_03 AC 43 ms
49,452 KB
testcase_04 AC 48 ms
49,472 KB
testcase_05 AC 47 ms
49,768 KB
testcase_06 AC 56 ms
50,924 KB
testcase_07 AC 48 ms
50,140 KB
testcase_08 AC 59 ms
51,252 KB
testcase_09 AC 51 ms
49,568 KB
testcase_10 AC 57 ms
50,900 KB
testcase_11 AC 57 ms
50,548 KB
testcase_12 AC 45 ms
49,424 KB
testcase_13 AC 70 ms
50,668 KB
testcase_14 AC 58 ms
50,804 KB
testcase_15 AC 57 ms
51,604 KB
testcase_16 AC 57 ms
50,792 KB
testcase_17 AC 54 ms
49,524 KB
testcase_18 AC 49 ms
50,136 KB
testcase_19 AC 130 ms
54,996 KB
testcase_20 AC 259 ms
58,388 KB
testcase_21 AC 106 ms
54,448 KB
testcase_22 AC 214 ms
56,432 KB
testcase_23 AC 108 ms
52,360 KB
testcase_24 AC 162 ms
56,784 KB
testcase_25 AC 86 ms
52,304 KB
testcase_26 AC 190 ms
55,572 KB
testcase_27 AC 268 ms
58,608 KB
testcase_28 AC 270 ms
58,800 KB
testcase_29 AC 208 ms
56,632 KB
testcase_30 AC 259 ms
58,972 KB
testcase_31 AC 189 ms
56,024 KB
testcase_32 AC 281 ms
58,728 KB
testcase_33 AC 121 ms
55,904 KB
testcase_34 AC 255 ms
58,588 KB
testcase_35 AC 193 ms
56,392 KB
testcase_36 AC 247 ms
59,028 KB
testcase_37 AC 228 ms
58,340 KB
testcase_38 AC 137 ms
54,904 KB
testcase_39 AC 267 ms
58,852 KB
testcase_40 AC 267 ms
58,544 KB
testcase_41 AC 252 ms
58,516 KB
testcase_42 AC 269 ms
59,052 KB
testcase_43 AC 267 ms
58,648 KB
testcase_44 AC 404 ms
61,560 KB
testcase_45 AC 423 ms
59,416 KB
testcase_46 AC 408 ms
60,316 KB
testcase_47 AC 260 ms
58,784 KB
testcase_48 AC 228 ms
56,956 KB
testcase_49 AC 275 ms
58,584 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