I题不用multiset直接用set也能过,建议强化数据。本来不能过的代码: #include <iostream> #include <cstring> #include <algorithm> #include <set> using namespace std; const int N = 100010; struct Point{     int x,y,z;     bool operator<(const Point &a) const     {         if(x != a.x) return x < a.x;         if(y != a.y) return y < a.y;         return z < a.z;      } }; int n; Point p[N]; int main() {     //freopen("data.in","r",stdin);     //freopen("data.out","w",stdout);     ios :: sync_with_stdio(false);     cin.tie(0);     cin >> n;     for(int i=1;i<=n;i++)         cin >> p[i].x >> p[i].y >> p[i].z;          sort(p + 1,p + n + 1);     reverse(p + 1,p + n + 1);     set<int> s;     int res = 0;     for(int i=1;i<=n;i++)     {         int x = p[i].x;         int y = p[i].y;         int z = p[i].z;         if(z == 1) s.insert(y);         else         {             auto it = s.upper_bound(y);             if(it != s.end())             {                 res ++;                 s.erase(it);             }                 }              }     cout << res << endl;     return 0; }
点赞 1

相关推荐

迷茫的大四🐶:价格这么低都能满了?
点赞 评论 收藏
分享
牛客吹哨人:哨哥晚点统一更新到黑名单:能救一个是一个!26届毁意向毁约裁员黑名单https://www.nowcoder.com/discuss/1525833
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务