結果

問題 No.2220 Range Insert & Point Mex
ユーザー no wayno way
提出日時 2023-02-18 12:51:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,146 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 172,776 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2023-09-28 18:19:59
合計ジャッジ時間 6,020 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,616 KB
testcase_01 AC 2 ms
5,532 KB
testcase_02 AC 2 ms
5,672 KB
testcase_03 AC 2 ms
5,520 KB
testcase_04 AC 2 ms
5,620 KB
testcase_05 AC 2 ms
5,604 KB
testcase_06 AC 2 ms
5,544 KB
testcase_07 AC 2 ms
5,828 KB
testcase_08 AC 2 ms
5,644 KB
testcase_09 AC 2 ms
5,552 KB
testcase_10 AC 2 ms
5,612 KB
testcase_11 AC 2 ms
5,544 KB
testcase_12 AC 2 ms
5,584 KB
testcase_13 AC 100 ms
6,496 KB
testcase_14 AC 99 ms
6,484 KB
testcase_15 AC 99 ms
6,592 KB
testcase_16 AC 99 ms
6,572 KB
testcase_17 AC 99 ms
6,468 KB
testcase_18 AC 99 ms
6,608 KB
testcase_19 AC 99 ms
6,468 KB
testcase_20 AC 85 ms
6,596 KB
testcase_21 AC 86 ms
6,476 KB
testcase_22 AC 86 ms
6,508 KB
testcase_23 AC 65 ms
7,424 KB
testcase_24 AC 55 ms
7,316 KB
testcase_25 AC 54 ms
6,468 KB
testcase_26 AC 64 ms
7,300 KB
testcase_27 AC 44 ms
7,216 KB
testcase_28 AC 21 ms
5,548 KB
testcase_29 AC 23 ms
5,604 KB
testcase_30 AC 23 ms
5,532 KB
testcase_31 AC 58 ms
6,920 KB
testcase_32 AC 51 ms
6,308 KB
testcase_33 AC 53 ms
6,188 KB
testcase_34 AC 70 ms
6,404 KB
testcase_35 AC 72 ms
6,240 KB
testcase_36 AC 71 ms
6,420 KB
testcase_37 AC 71 ms
6,432 KB
testcase_38 AC 70 ms
6,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
	int l,r,x;
}a[N];
bool operator<(const node&x,const node&y){
	return x.l<y.l;
}
int n,m,x;
int tree[N<<2],sum[N<<2];
void change(int l,int r,int k,int x,int op){
	if (l==r){
		sum[l]+=op;
		if (!sum[l]) tree[k]=l; else tree[k]=N;
	}else{
		int mid=(l+r)/2;
		if (x<=mid) change(l,mid,k<<1,x,op); else change(mid+1,r,k<<1|1,x,op);
		tree[k]=min(tree[k<<1],tree[k<<1|1]);
	}
}
void build(int l,int r,int k){
	if (l==r) tree[k]=l;
	else{
		int mid=(l+r)/2;
		build(l,mid,k<<1); build(mid+1,r,k<<1|1);
		tree[k]=l;
	}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].x);
	sort(a+1,a+n+1);
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
	scanf("%d",&m);
	build(1,n+1,1);
	int l=1;
	for (int i=1;i<=m;i++){
		scanf("%d",&x);
		while (l<=n&&a[l].l<=x){
			if (a[l].x+1<=n) change(1,n+1,1,a[l].x+1,1);
			q.push(make_pair(a[l].r,a[l].x+1));
			l++;
		}
		while (!q.empty()&&q.top().first<x){
			if (q.top().second<=n) change(1,n+1,1,q.top().second,-1);
			q.pop();
		}
		printf("%d\n",tree[1]-1);
	}
}
0