結果

問題 No.610 区間賞(Section Award)
ユーザー TAISA_TAISA_
提出日時 2018-06-05 23:38:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 157,784 KB
実行使用メモリ 9,520 KB
最終ジャッジ日時 2023-09-12 22:37:47
合計ジャッジ時間 7,195 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 24 ms
4,528 KB
testcase_20 AC 144 ms
8,964 KB
testcase_21 AC 16 ms
4,376 KB
testcase_22 AC 90 ms
6,932 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 29 ms
4,772 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 58 ms
5,840 KB
testcase_27 AC 137 ms
8,640 KB
testcase_28 AC 121 ms
8,100 KB
testcase_29 AC 81 ms
6,724 KB
testcase_30 AC 110 ms
7,844 KB
testcase_31 AC 53 ms
5,752 KB
testcase_32 AC 130 ms
8,432 KB
testcase_33 AC 16 ms
4,380 KB
testcase_34 AC 146 ms
8,808 KB
testcase_35 AC 59 ms
5,984 KB
testcase_36 AC 131 ms
8,856 KB
testcase_37 AC 107 ms
7,716 KB
testcase_38 AC 26 ms
4,604 KB
testcase_39 AC 150 ms
8,932 KB
testcase_40 AC 147 ms
8,808 KB
testcase_41 AC 145 ms
8,848 KB
testcase_42 AC 143 ms
8,916 KB
testcase_43 AC 142 ms
8,872 KB
testcase_44 AC 225 ms
8,436 KB
testcase_45 AC 277 ms
9,508 KB
testcase_46 AC 279 ms
9,520 KB
testcase_47 AC 112 ms
7,872 KB
testcase_48 AC 103 ms
7,564 KB
testcase_49 AC 115 ms
7,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int a[100010],b[100010];
struct BinaryIndexedTree{
    vector<int> bit;
    BinaryIndexedTree(int siz){
        bit.assign(++siz,0);
    }

    int sum(int k){
        int ret=0;
        for(++k;k>0;k-=k&-k){
            ret+=bit[k];
        }
        return ret;
    }

    void add(int k,int x){
        for(++k;k<bit.size();k+=k&-k){
            bit[k]+=x;
        }
    }
};
int main(){
	int n;cin>>n;
	map<int,int> mp;
	BinaryIndexedTree bit(n+1);
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]=i+1;
	}
	for(int j=0;j<n;j++){
		cin>>b[j];
	}
	vector<int> ans;
	for(int i=0;i<n;i++){
		if(bit.sum(n)-bit.sum(mp[b[i]])==0){
			ans.push_back(b[i]);
		}
		bit.add(mp[b[i]],1);
	}
	sort(all(ans));
	for(auto a:ans){
		cout<<a<<endl;
	}
	return 0;
}
0