algorithm_2024/P1311/P1311.cpp

31 lines
669 B
C++
Raw Normal View History

2024-10-02 16:40:29 +00:00
#include<iostream>
2024-10-02 09:13:26 +00:00
2024-10-02 16:40:29 +00:00
using std::cin,std::cout,std::iostream;
2024-10-02 09:13:26 +00:00
2024-10-02 16:40:29 +00:00
const int MAX_COLOR = 50+5;
int price,color,n,k,p,last_coffee_shop,last_hotel[MAX_COLOR],left_hotel_num[MAX_COLOR],cnt_hotel_num[MAX_COLOR],ans;
2024-10-02 09:13:26 +00:00
int main(){
2024-10-02 16:40:29 +00:00
iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
2024-10-02 09:13:26 +00:00
cin>>n>>k>>p;
2024-10-02 16:40:29 +00:00
for(int i=1;i<=n;i++){
cin>>color>>price;
if(price<=p){
last_coffee_shop = i;
}
if(last_hotel[color] <= last_coffee_shop){
left_hotel_num[color] = cnt_hotel_num[color];
}
last_hotel[color]=i;
ans+=left_hotel_num[color];
cnt_hotel_num[color]++;
2024-10-02 09:13:26 +00:00
}
2024-10-02 16:40:29 +00:00
cout<<ans<<"\n";
2024-10-02 09:13:26 +00:00
}