20pts 求助
查看原帖
20pts 求助
361141
_JF_殉情楼主2023/8/1 14:17
#include<bits/stdc++.h>
using namespace std;
const int N =3e5+10;
#define int long long 
int g[70][N],a[N],b[N];
signed main()
{
//	freopen("a.in.txt","r",stdin);
//	freopen("ans.out","w",stdout);
	int n,k,p;	cin>>n>>k>>p;
	for(int i=1,x;i<=n;i++)	
		cin>>a[i]>>b[i],g[a[i]][i]++;
	for(int i=0;i<k;i++)
		for(int j=1;j<=n;j++)	g[i][j]+=g[i][j-1];
	int l=1,r=1,ans=0;
	while(r<=n){
		if(b[r]<=p){
			while(l<=r){
				if(l<r)
					ans+=g[a[l]][n]-g[a[l]][r-1],l++;
				else
					ans+=g[a[l]][n]-g[a[l]][r],l++;
			}
			r=l+1;
		}
		else 
			r++;
	}
	cout<<ans<<endl;
	return 0;
}
/*
5 2 10
0 11
1 5
0 12
0 6
1 11

4
*/ 

2023/8/1 14:17
加载中...