結果

問題 No.610 区間賞(Section Award)
ユーザー TANIGUCHI Kousuke
提出日時 2017-12-12 10:13:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 76,432 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 04:50:00
合計ジャッジ時間 3,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#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