if(p2.color==p1.color),ans++。
#include<cstdio> #include<iostream> #include<cstring> using namespace std; struct s { int a,b,c; }s[2000005]; int main() { int n,k,p; int ans=0; int tmp=0; scanf("%d%d%d",&n,&k,&p); for(int i=1;i<=n;i++) { int co,h; scanf("%d%d",&co,&h); if(h<=p) tmp=i; if(tmp>=s[co].a) s[co].c=s[co].b; s[co].a=i; ans+=s[co].c; s[co].b++; } printf("%d",ans); }
Comments NOTHING