Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct cmp {
- bool operator() (int a, int b) const {
- return a > b;
- }
- };
- int main(){
- #ifdef ERFANUL007
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int t, cs = 0;
- scanf("%d", &t);
- while(t--){
- printf("Case %d: ", ++cs);
- int n; scanf("%d", &n);
- vector< int > shuru[n*2+2];
- vector< int > sesh[n*2+2];
- for(int i=1; i<=n; i++){
- int l, r; scanf("%d %d", &l, &r);
- shuru[l].push_back(i);
- sesh[r].push_back(i);
- }
- bool show[n+2];
- memset(show, 0, sizeof(show));
- set< int, cmp> pq;
- for(int i=1; i<=2*n; i++){
- for(auto it : shuru[i]){
- pq.insert(it);
- }
- if(pq.size()){
- show[*pq.begin()] = 1;
- }
- for(auto it : sesh[i]){
- pq.erase(pq.find(it));
- }
- }
- int ans = 0;
- for(int i=1; i<=n; i++) if(show[i]) ans++;
- printf("%d\n", ans);
- }
- #ifdef ERFANUL007
- fprintf(stderr, "\n>>> Runtime : %.9f\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement