Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
129172 陆妍凯 选择客栈 C++ 通过 100 80 MS 1844 KB 546 2024-01-26 16:34:01

Tests(10/10):


#include<iostream> #include<cstdio> using namespace std; const int NR=(2e6)+10; int a[NR],b[NR],bucket[NR],sum[NR],pre[NR]; int main() { // freopen("P6032.in","r",stdin); // freopen("P6032.out","w",stdout); // std::ios::sync_with_stdio(false); // std::cin.tie(0); int n,k,p,i,x=0; long long ans=0; cin>>n>>k>>p; for(i=1;i<=n;i++) cin>>a[i]>>b[i]; for(i=1;i<=n;i++) { if(b[i]<=p) x=i; if(pre[a[i]]<=x) sum[a[i]]=bucket[a[i]]; bucket[a[i]]++; ans+=1ll*sum[a[i]]; pre[a[i]]=i; } cout<<ans; return 0; }


测评信息: