| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 125139 | 林扬泉 | 选择客栈 | C++ | Accepted | 100 | 21 MS | 1036 KB | 591 | 2024-01-23 16:28:01 |
#include<bits/stdc++.h> using namespace std; const int N=2e5+10; int n,k,p; int t;//当前枚举客栈过程中 离我们枚举到的客栈最近的最低消费<=p的客栈的下标(第几个客栈) int res,price; int num[110];//在t前面的各个颜色的客栈有多少个 int color[N]; int main(){ scanf("%d%d%d",&n,&k,&p); for(int i=1;i<=n;i++){ scanf("%d%d",&color[i],&price); if(price<=p){ for(int j=i;j>t;j--){ num[color[j]]++; } t=i; res+=num[color[i]]-1; } else{ res+=num[color[i]]; } } printf("%d\n",res); return 0; }