結果
問題 | No.610 区間賞(Section Award) |
ユーザー |
👑 |
提出日時 | 2020-03-18 13:58:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 191 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 977 ms |
コンパイル使用メモリ | 89,240 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-12-14 01:49:46 |
合計ジャッジ時間 | 5,381 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
#include <iostream>#include <queue>#include <set>#include <vector>#include <algorithm>using namespace std;int main(){int n;cin>>n;int a[n],b[n];for(int i = 0; n > i; i++){cin>>a[i];}for(int i = 0; n > i; i++){cin>>b[i];}queue<int> Z;set<int> A;vector<int> ans;for(int i = n-1; 0 <= i; i--){Z.push(a[i]);if((Z.size()&&Z.front()==b[i])){ans.push_back(b[i]);Z.pop();while(!Z.empty()&&A.find(Z.front())!=A.end())Z.pop();}else{A.insert(b[i]);}}sort(ans.begin(),ans.end());for(int i = 0; ans.size() > i; i++){cout << ans[i] << endl;}}