记录编号 |
199719 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2011]选择客栈 |
最终得分 |
100 |
用户昵称 |
Bokjan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.045 s |
提交时间 |
2015-10-27 13:53:10 |
内存使用 |
1.07 MiB |
显示代码纯文本
#define FOR(i, s, t) for(int i = s; i != t; ++i)
#define ROF(i, s, t) for(int i = s; i != t; --i)
#define REP(i, s, t) for(int i = s; i <= t; ++i)
#define PER(i, s, t) for(int i = s; i >= t; --i)
#define FOREACH(t, i, c) for(t::iterator i = c.begin();\
i != c.end(); ++i)
#define SQ(x) ((x)*(x))
#define MAX(a, b) ((a)>(b)?(a):(b))
#define MIN(a, b) ((a)<(b)?(a):(b))
#define ABS(x) ((x)>0?(x):(-(x)))
#define FI(x) freopen(x, "r", stdin)
#define FO(x) freopen(x, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#include <cstdio>
#include <vector>
template <typename T>
inline void RU(T &x)
{
x = 0;
char c = getchar();
while(c < '0' || c > '9')
c = getchar();
while(c >= '0' && c <= '9')
{
x = x * 10 + c - '0';
c = getchar();
}
}
const int MAXK = 50 + 10;
const int MAXN = 200000 + 10;
int n, k, p;
int sum[MAXN];
std::vector<int> g[MAXK];
void Read(void)
{
RU(n), RU(k), RU(p);
int color, price;
REP(i, 1, n)
{
RU(color), RU(price);
g[color].push_back(i);
if(price <= p)
sum[i] = sum[i - 1] + 1;
else
sum[i] = sum[i - 1];
}
}
void Solve(void)
{
int ans = 0;
FOR(i, 0, k)
{
for(std::vector<int>::iterator it1 = g[i].begin();
it1 != g[i].end() - 1; ++it1)
for(std::vector<int>::iterator it2 = it1 + 1;
it2 != g[i].end(); ++it2)
{
if(sum[*it2] - sum[*it1 - 1] > 0)
{
ans += (int)(g[i].end() - it2);
break;
}
}
}
printf("%d\n", ans);
}
int main(void)
{
FI("hotel.in");
FO("hotel.out");
Read();
Solve();
return 0;
}