1 #include<cstdio> 2 #include<iostream> 3 #include<cmath> 4 #include<string> 5 #include<cstring> 6 #include<algorithm> 7 #include<vector> 8 #include<queue> 9 #include<stack> 10 #include<iomanip> 11 #include<cstdlib> 12 using namespace std; 13 struct data{ 14 int sd,xf; 15 }; 16 data co[200005]; 17 int n,k,p,ans,cnt,minn=210000,s; 18 int sum[55][200005],st[200005]; 19 int main() 20 { 21 freopen ("hotel.in","r",stdin); 22 //freopen ("hotel.out","w",stdout); 23 scanf ("%d%d%d",&n,&k,&p); 24 for (int i=1;i<=n;i++) 25 { 26 scanf ("%d%d",&co[i].sd,&co[i].xf); 27 for (int j=0;j<k;j++) 28 { 29 if (j==co[i].sd) sum[j][i]=sum[j][i-1]+1; 30 else sum[j][i]+=sum[j][i-1]; 31 } 32 } 33 for (int i=n;i>=1;i--)//here 34 { 35 if (co[i].xf<=p) minn=min(minn,i); 36 st[i]=minn; 37 } 38 for (int i=1;i<=n-1;i++) 39 { 40 if (st[i]>200000) continue; 41 if (st[i]==i) ans+=sum[co[i].sd][n]-sum[co[i].sd][i]; 42 else ans+=sum[co[i].sd][n]-sum[co[i].sd][st[i]-1]; 43 } 44 printf ("%d",ans); 45 return 0; 46 }
时间: 2024-10-14 16:15:21