結果

問題 No.2220 Range Insert & Point Mex
ユーザー 👑 kmjpkmjp
提出日時 2023-02-17 22:57:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 352 ms / 2,000 ms
コード長 1,456 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 218,772 KB
実行使用メモリ 21,948 KB
最終ジャッジ日時 2023-09-28 18:13:29
合計ジャッジ時間 12,433 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
13,104 KB
testcase_01 AC 59 ms
12,908 KB
testcase_02 AC 59 ms
12,868 KB
testcase_03 AC 59 ms
12,980 KB
testcase_04 AC 59 ms
12,932 KB
testcase_05 AC 59 ms
12,992 KB
testcase_06 AC 58 ms
12,884 KB
testcase_07 AC 58 ms
12,876 KB
testcase_08 AC 59 ms
12,980 KB
testcase_09 AC 59 ms
13,016 KB
testcase_10 AC 60 ms
12,856 KB
testcase_11 AC 59 ms
12,792 KB
testcase_12 AC 60 ms
12,796 KB
testcase_13 AC 273 ms
18,844 KB
testcase_14 AC 272 ms
18,000 KB
testcase_15 AC 271 ms
18,328 KB
testcase_16 AC 274 ms
18,252 KB
testcase_17 AC 273 ms
18,444 KB
testcase_18 AC 269 ms
18,980 KB
testcase_19 AC 270 ms
18,548 KB
testcase_20 AC 239 ms
15,032 KB
testcase_21 AC 241 ms
15,032 KB
testcase_22 AC 240 ms
15,076 KB
testcase_23 AC 352 ms
21,876 KB
testcase_24 AC 259 ms
20,372 KB
testcase_25 AC 290 ms
17,240 KB
testcase_26 AC 322 ms
21,948 KB
testcase_27 AC 181 ms
19,904 KB
testcase_28 AC 198 ms
13,912 KB
testcase_29 AC 196 ms
14,060 KB
testcase_30 AC 199 ms
14,044 KB
testcase_31 AC 239 ms
18,328 KB
testcase_32 AC 236 ms
15,392 KB
testcase_33 AC 244 ms
15,452 KB
testcase_34 AC 266 ms
15,832 KB
testcase_35 AC 262 ms
15,692 KB
testcase_36 AC 262 ms
15,704 KB
testcase_37 AC 269 ms
15,836 KB
testcase_38 AC 306 ms
18,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N;
int L[101010],R[101010],A[101010];
int Q;
int X[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	vector<pair<int,int>> ev;
	FOR(i,N) {
		cin>>L[i]>>R[i]>>A[i];
		if(A[i]>200000) continue;
		ev.push_back({L[i],i});
		ev.push_back({R[i],2000000+i});
	}
	set<int> alone;
	map<int,int> M;
	FOR(i,202020) alone.insert(i);
	
	cin>>Q;
	FOR(i,Q) {
		cin>>X[i];
		ev.push_back({X[i],1000000+i});
	}
	
	sort(ALL(ev));
	FORR2(a,i,ev) {
		if(i<1000000) {
			alone.erase(A[i]);
			M[A[i]]++;
		}
		else if(i>=2000000) {
			i-=2000000;
			M[A[i]]--;
			if(M[A[i]]==0) alone.insert(A[i]);
		}
		else {
			cout<<*alone.begin()<<endl;
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0