hdu5596GTW likes gt stl set

#include<cstdio>
#include<cstring>
#include<iostream>
#include<set>
using namespace std ;
const int maxn = 50000+10 ;
multiset<int> se[2] ;
int id[maxn] ;
int b[maxn] ;
int c[maxn] ;
int main()
{
    int t ;
    scanf("%d" , &t) ;
    while(t--){
        int n , m ;
        scanf("%d%d" , &n , &m) ;
        for(int i = 1;i <= n;i++){
            scanf("%d%d" , &id[i] , &b[i]) ;
        }
        memset(c , 0 ,sizeof(c)) ;
        se[0].clear()  ;
        se[1].clear() ;
        for(int i = 1;i <= m;i++){
            int tmp ;
            scanf("%d" , &tmp) ;
            c[tmp]++ ;
        }
        multiset<int>::iterator it ,x;
        int sum = 0 ;
        for(int i = 1;i <= n;i++){
            int pos = id[i] ;
            if(se[!pos].size()){
                for(it = se[!pos].begin();(it!=se[!pos].end())&&(*it<(b[i]-sum));){
                    se[!pos].erase(it++) ;
                }
            }
            se[pos].insert(b[i]-sum) ;
            sum += c[i] ;
        }
        printf("%d\n" , se[0].size() + se[1].size()) ;
    }
    return 0 ;
}

你可能感兴趣的:(hdu5596GTW likes gt stl set)