#include<cstdio>
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstdlib>
using namespace std;
struct data{
int sd,xf;
};
data co[200005];
int n,k,p,ans,cnt,minn=210000,s;
int sum[55][200005],st[200005];
int main()
{
freopen ("hotel.in","r",stdin);
//freopen ("hotel.out","w",stdout);
scanf ("%d%d%d",&n,&k,&p);
for (int i=1;i<=n;i++)
{
scanf ("%d%d",&co[i].sd,&co[i].xf);
for (int j=0;j<k;j++)
{
if (j==co[i].sd) sum[j][i]=sum[j][i-1]+1;
else sum[j][i]+=sum[j][i-1];
}
}
for (int i=n;i>=1;i--)//here
{
if (co[i].xf<=p) minn=min(minn,i);
st[i]=minn;
}
for (int i=1;i<=n-1;i++)
{
if (st[i]>200000) continue;
if (st[i]==i) ans+=sum[co[i].sd][n]-sum[co[i].sd][i];
else ans+=sum[co[i].sd][n]-sum[co[i].sd][st[i]-1];
}
printf ("%d",ans);
return 0;
}
NOIP 2011 Day1 T2 选择客栈
最新推荐文章于 2023-05-02 15:48:26 发布