結果

問題 No.610 区間賞(Section Award)
ユーザー たこし
提出日時 2017-12-16 11:23:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 162,940 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-14 19:12:48
合計ジャッジ時間 5,773 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using LL = long long int;

const int MAX_N = 100005;

int N;
int A[MAX_N], B[MAX_N];
int AIndex[MAX_N];

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    AIndex[A[i]] = i;
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }


  int ansIndex = 0;
  vector<int> ansList;
  for(int i = 0; i < N; i++) {
    if(AIndex[B[i]] < ansIndex) {
      continue;
    } else {
      ansIndex = AIndex[B[i]];
      ansList.push_back(B[i]);
    }
  }

  sort(begin(ansList), end(ansList));
  for(int ans : ansList) {
    cout << ans << endl;
  }

  return 0;
}
0