#include using namespace std; typedef long long ll; typedef pair pll; typedef long double ld; typedef pair pdd; #define vec vector #define For(i, a, n) for(ll i=(ll)a;i pairoperator+(const pair&a, const pair&b){ return {a.first + b.first, a.second + b.second}; } template ostream&operator<<(ostream&os, const pair&c){ return os<<"("< basic_ostream&operator<<(basic_ostream&os, const C&c){ for(auto itr=begin(c);itr!=end(c);++itr){ os<<(itr==begin(c)?"":" ")<<*itr; } return os; } template void dbg(Args&&...args){ //((cerr<query(l, r), right->query(l, r)); } Node* update(ll l, ll r, ll x){ if(l<=z && k<=r){ // toto sa stane iba v liste Node* ans = new Node(z, k, h); ans->h +=x; vytvor_deti(); return ans; } if(r<=z||k<=l)return this; vytvor_deti(); Node* ans = new Node(z, k, fill); ans->left = left->update(l, r, x); ans->right = right->update(l, r, x); ans->h = f(ans->left->h, ans->right->h); return ans; } }; void solve(){ ll n,c,q; cin >> n >> c >> q; vector> people(n); ll latest = -1; For(i,0,n){ ll x,y; cin >> x >> y; people[i] = {x,y}; latest = max(latest,y); } sort(people.begin(),people.end()); Node* intervalac = new Node(latest+1, 0); vec nodes; ll pos = 0; For(i,0,latest+1){ while(pos < n && people[pos].first == i){ intervalac = intervalac->update(people[pos].second, people[pos].second+1, 1); pos++; } //dbg(intervalac->query(meeting,*dalsie) , nodes[*minule]->query(meeting,*dalsie)); nodes.push_back(intervalac); } set actual_meetings; actual_meetings.insert(0); actual_meetings.insert(latest+1); ll chudaci = 0; For(i,0,c){ ll meeting; cin >> meeting; if(meeting > latest){ continue; } auto dalsie = actual_meetings.lower_bound(meeting); auto minule = --actual_meetings.lower_bound(meeting); dbg(*minule,*dalsie); dbg(nodes[meeting]->query(meeting,*dalsie) , nodes[*minule]->query(meeting,*dalsie)); chudaci += nodes[meeting]->query(meeting,*dalsie) - nodes[*minule]->query(meeting,*dalsie); dbg("zjednem",chudaci); actual_meetings.insert(meeting); } cout << n-chudaci << "\n"; For(i,0,q){ ll from,to; cin >> from >> to; if(from <= latest){ actual_meetings.erase(from); dbg("erased"); auto dalsie = actual_meetings.lower_bound(from); auto minule = --actual_meetings.lower_bound(from); dbg(*minule,*dalsie); chudaci -= nodes[from]->query(from,*dalsie) - nodes[*minule]->query(from,*dalsie); } if(to <= latest){ auto dalsie = actual_meetings.lower_bound(to); auto minule = --actual_meetings.lower_bound(to); dbg(*minule,*dalsie); chudaci += nodes[to]->query(to,*dalsie) - nodes[*minule]->query(to,*dalsie); actual_meetings.insert(to); dbg("inserted",actual_meetings); } dbg("teraz vypisem",n-chudaci); cout <sync_with_stdio(0); cin.exceptions(cin.failbit); int t = 1; while(t--)solve(); return 0; }