結果
| 問題 | No.610 区間賞(Section Award) | 
| コンテスト | |
| ユーザー |  pin | 
| 提出日時 | 2017-12-11 12:37:50 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 194 ms / 2,000 ms | 
| コード長 | 826 bytes | 
| コンパイル時間 | 784 ms | 
| コンパイル使用メモリ | 89,312 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-30 11:34:37 | 
| 合計ジャッジ時間 | 4,074 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 50 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int num[100005], pos[100005], n;
bool f[100005];
vector<int> ans;
int main(void){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> num[i];
        pos[num[i]] = i;
        f[i + 1] = true;
    }
    int pre = -1;
    for (int i = 0; i < n; i++){
        int s;
        cin >> s;
        if (!f[s]) continue;
        int p = pos[s] - 1;
        while (p != pre){
            f[num[p]] = false;
            p--;
        }
        ans.push_back(s);
        pre = pos[s];
    }
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}
            
            
            
        