Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
124947 | 硕博·黄凯麟·连读 | 选择客栈 | C++ | 通过 | 100 | 44 MS | 272 KB | 403 | 2024-01-23 16:13:07 |
#include<bits/stdc++.h> using namespace std; int n,k,p; int co,pr; int cnt[301000],last[301000],sum[301000],now,ans; //sum[i]表示 当前now前面的颜色i数数量。 int main(){ cin>>n>>k>>p; for(int i = 1;i <= n;i++){ cin>>co>>pr; if(pr <= p){ now = i; } if(last[co]<= now){ sum[co] = cnt[co]; } last[co] = i; ans+=sum[co]; cnt[co]++; } cout<<ans; }