链接:https://ac.nowcoder.com/acm/contest/3005/I
来源:牛客网

示例1

输入

复制
2
1 1 0
2 2 1

2
1 1 0
2 2 1

输出

复制 1

1
示例2

输入

复制 2
1 1 1
2 2 1

2
1 1 1
2 2 1

输出

复制 0

0

备注:

思路:

  

 #include <bits/stdc++.h>
#define dbg(x) cout << #x << "=" << x << endl using namespace std;
typedef long long LL; template<class T>inline void read(T &res)
{
char c;T flag=;
while((c=getchar())<''||c>'')if(c=='-')flag=-;res=c-'';
while((c=getchar())>=''&&c<='')res=res*+c-'';res*=flag;
} namespace _buff {
const size_t BUFF = << ;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
if (ib == ie) {
ib = ibuf;
ie = ibuf + fread(ibuf, , BUFF, stdin);
}
return ib == ie ? - : *ib++;
}
} int qread() {
using namespace _buff;
int ret = ;
bool pos = true;
char c = getc();
for (; (c < '' || c > '') && c != '-'; c = getc()) {
assert(~c);
}
if (c == '-') {
pos = false;
c = getc();
}
for (; c >= '' && c <= ''; c = getc()) {
ret = (ret << ) + (ret << ) + (c ^ );
}
return pos ? ret : -ret;
} const int maxn = 1e5 + ; set <int> s;
map<int, int> mapp; int n; struct node {
int x,y,z;
}a[maxn]; bool cmp(node a, node b) {
if(a.x == b.x) {
return a.z > b.z;
}
return a.x < b.x;
} int main()
{
read(n);
for(int i = ; i <= n; ++i) {
scanf("%d %d %d",&a[i].x, &a[i].y, &a[i].z);
}
sort(a+, a+n+, cmp);
set<int>::iterator it; LL ans = ;
for(int i = ; i <= n; ++i) {
if(a[i].z == ) {
if(!mapp[a[i].y]) {
s.insert(a[i].y);
}
mapp[a[i].y]++;
}
if(a[i].z == ) {
it = s.lower_bound(a[i].y);
if(it != s.begin()) {
mapp[*it]--;
if(!mapp[*it]) {
s.erase(*it);
}
dbg(*it);
ans++;
}
}
}
cout << ans << endl;
return ;
}
/*
5
1 1 0
2 2 0
3 3 0
4 4 0
5 5 1
*/

最新文章

  1. ionic cordova 热更新(引用自www.zyyapp.com/post/116.html)
  2. hihocoder 1066 无间道之并查集
  3. play app to war
  4. Android客户端调用Asp.net的WebService
  5. MFC修改任务栏图标及程序运行exe图标
  6. twitter 监控登陆活动
  7. Hibernate 总结一
  8. 戏说云计算之PaaS,IaaS,SaaS【转载】
  9. 浅谈Android五大布局
  10. JAVA课设---五子棋
  11. python + selenium 自动化测试框架
  12. Java 与C++的各种优势与弱点--学习更新中
  13. leaflet渲染mapbox gl的矢量数据
  14. New UWP Community Toolkit - DropShadowPanel
  15. return_fun.go 源码阅读
  16. js获取浏览器窗体最大化事件
  17. ERROR 1045 (28000): Access denied for user &#39;mysql&#39;@&#39;localhost&#39; (using password: YES
  18. Python 之 __new__() 方法与实例化(转)
  19. python日志和异常
  20. 2-5 re模块练习题

热门文章

  1. SpringBoot、Spring MVC报错:Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  2. 什么是JWT以及具体应用
  3. 《python可以这样学》第二章
  4. C语言程序转汇编代码
  5. win10上使用linux命令
  6. 通过LD_PRELOAD绕过disable_functions
  7. SAP MM 一个含有多个账号分配对象的行项目的PO及其收货
  8. .Net框架的模块代码生成器--其三(dotnet tool指令的参数)
  9. 返回一个整数数组中最大子数组的和——java程序设计
  10. pgspider gzip fdw试用(集成gzip+http+graphql-engine)