- 选择客栈
- 2015-10-04 19:25:21 @
1 条评论
-
随波逐流 LV 8 @ 2015-10-04 19:41:42
#include<cstdio>
#include<queue>
#include<iostream>
using namespace std;int s[200005];
queue<int> q[55];
int main(){
int n,k,p,x;
scanf("%d%d%d",&n,&k,&p);
for(int i=1;i<=n;i++){
scanf("%d%d",&x,&s[i]);
q[x].push(i);
}long long ans=0;
for(int i=0;i<k;i++){
if(q[i].empty())continue;
queue<int> q2=q[i];while(!q[i].empty()){
int u=q[i].front();
q[i].pop();while(!q2.empty()){
int v=q2.front();
q2.pop();
if(v>u){
for(int t=u;t<=v;t++){
if(s[t] <= p){
ans++;
break;
}
}
}
}
}
}cout<<ans<<endl;
return 0;
}
- 1