# spoj niceday

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;
}



#### SPOJ简介

2016-07-26 11:02:13

#### SPOJ QTREE 系列

2015-08-04 00:14:26

#### spoj DQUERY D-query SPOJ -(主席树)

2017-08-27 10:14:47

#### SPOJ DIVCNT2

2016-11-16 16:19:20

#### SPOJ DIVCNT2（莫比乌斯反演+杜教筛）

2017-06-01 22:02:25

#### SPOJ GSS

2016-02-22 21:37:36

#### [SPOJ8222]NSUBSTR - Substrings

2016-04-04 11:19:48

#### SPOJ-ZQUERY(分块)

2017-09-15 19:41:17

#### SPOJ DQUERY D-query 莫队算法

2016-09-03 11:27:15

#### [SPOJ TSUM]Triple Sums(FFT+生成函数+容斥原理)

2015-03-12 21:59:50