結果

問題 No.610 区間賞(Section Award)
ユーザー TANIGUCHI Kousuke
提出日時 2017-12-11 18:57:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 77,360 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 11:40:14
合計ジャッジ時間 3,933 ms
ジャッジサーバーID
(参考情報)
judge3 / 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 100000
int main(void){
    int n;

    vector<int> s(N),t(N),w(N),ans;
    
    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