spoj niceday
2015-07-07 15:15
218 查看
http://www.spoj.com/problems/NICEDAY/
//http://www.spoj.com/problems/NICEDAY/ #include <iostream> #include <cstring> #include <string> #include <cstdio> #include <vector> #include <algorithm> using namespace std; const int MAXN = 100005; int c[MAXN]; struct Triple { int a, b, c; bool operator < (const Triple &t) const { return a < t.a; } }triple[MAXN]; int lowbit(int n){ return n & (n ^ (n - 1)); } int checkmin(int p){ int ret = c[p]; while (p) { ret = min(ret, c[p]); p -= lowbit(p); } return ret; } void update(int p, int v, int n) { while (p <= n) { c[p] = min(c[p], v); p += lowbit(p); } } int main() { int T, n; cin>>T; while (T--) { cin>>n; for (int i = 0; i < n; ++i) { scanf("%d%d%d", &triple[i].a, &triple[i].b, &triple[i].c); } sort(triple, triple + n); memset(c, 0x3f, sizeof(int) * (n + 1)); int excellent = 0; for (int i = 0; i < n; ++i) { int rank = checkmin(triple[i].b); if (rank > triple[i].c) { ++excellent; } update(triple[i].b, triple[i].c, n); } cout<<excellent<<endl; } return 0; }
相关文章推荐
- HDU - 1556 Color the ball (线段树 + 区间更新)
- 【C语言】统计数组中出现次数超过一半的数字
- sql查询单个银行账号重复
- C#开发Unity游戏教程之游戏对象的属性变量
- Python实现爬取逐浪小说的方法
- cat proc/version在内核中是如何实现的?
- Struts框架之Action中多个业务方法处理
- 项目管理小知识——Alpha版本,Beta版本
- 【Linux 内核网络协议栈源码剖析】connect 函数剖析(二)
- 创建一个简单的Joomla!模块
- sort与qsort的应用
- 【C语言】调整数组使奇数全部都位于偶数前面
- Python下opencv使用笔记(一)(图像简单读取、显示与储存)
- Objective-C - NSObject常用方法
- 软件架构的数据流总结(一)
- java并发容器CopyOnWriteArrayList 使用场景和内部实现分析
- iOS 获取系统相机相册
- 使用Sublime Text 3做Python开发
- [leedcode 18] 4Sum
- MySQL 5.6 警告信息 command line interface can be insecure 修复