結果

問題 No.610 区間賞(Section Award)
ユーザー t98slider
提出日時 2023-08-08 01:32:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 173,712 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 07:11:11
合計ジャッジ時間 4,974 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n), ans;
    vector<bool> used(n + 1);
    for(auto &&v : a) cin >> v;
    for(auto &&v : b) cin >> v;
    int i = 0, j = 0;
    while(j < n){
        while(i < n && a[i] != b[j]){
            used[a[i]] = true;
            i++;
        }
        ans.emplace_back(b[j]);
        used[b[j]] = true;
        while(j < n && used[b[j]]) j++;
    }
    sort(ans.begin(), ans.end());
    for(auto &&v : ans) cout << v << '\n';
}
0