题目传送门
题解:
#include <bits/stdc++.h>
using namespace std;
int n,k,p;
int color,price;
int last[200005];
int sum[200005];
int cnt[200005];
int ans = 0;
int now;
int main() {
cin>>n>>k>>p;
for (int i=1;i<=n;i++) {
cin>>color>>price;
if (price<=p) {
now = i;
}
if (now>=last[color]) {
sum[color]=cnt[color];
}
last[color]=i;
ans+=sum[color];
cnt[color]++;
}
cout<<ans<<endl;
return 0;
}
有问题可以私发给我
邮箱:3153960338@qq.com