結果

問題 No.610 区間賞(Section Award)
コンテスト
ユーザー TANIGUCHI Kousuke
提出日時 2017-12-12 10:13:32
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 77 ms / 2,000 ms
+ 583µs
コード長 691 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 424 ms
コンパイル使用メモリ 92,980 KB
実行使用メモリ 9,824 KB
最終ジャッジ日時 2026-10-03 06:19:44
合計ジャッジ時間 4,150 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define N 100005

typedef vector<int> vi;

int main(void){

    int n;
    vi s(N);
    vi t(N);
    vi w(N);
    vi ans;
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    
    REP(i,n) cin >> s[i];
    REP(i,n) cin >> t[i];
    REP(i,n) w[s[i]] = i;
    
    int j = -1;
    REP(i,n) {
        if(w[t[i]] > j){
            ans.push_back(t[i]);
            j = w[t[i]];
        }
    }
    
    sort(ans.begin(), ans.end());
    for(vector<int>::iterator it = ans.begin(); it != ans.end(); it++){
        cout << *it << endl;
    }
    
}
0