#include <set> #include <vector> #include <iostream> #include <algorithm>   using namespace std; typedef long long ll;   struct P{     int a,b,c;     bool operator < (const P &rhs) const{         return a<rhs.a;     } }alp[300030]; int n; int main() {     cin>>n;     for(int i=0;i<n;i++) cin>>alp[i].a>>alp[i].b>>alp[i].c;     sort(alp,alp+n);     multiset<int> pool;     multiset<int>::iterator it;     int ans = 0;     for(int i=0;i<n;i++){         if(alp[i].c){             it = pool.lower_bound(alp[i].b);             if(it!=pool.begin()){                 --it;                 pool.erase(it);                 ans+=1;             }         }else{             pool.insert(alp[i].b);         }     }     cout<<ans<<endl;           return 0; } I题数据还有点问题,这个代码本来不应该过的但是过了,两个x值相同的星星连在一起了。
点赞 1

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务